Mysql database: I need to update a field in a table using another field in the same table. Example: My table TABLE1
contains two fields FIELD1
and FIELD2
. I need to do something along the line
UPDATE TABLE1
SET FIELD1 = (SELECT CONCAT('xyz',`FIELD2`) FROM TABLE1)
I need to update the field for all the records. No conditions. I tried executing the query but got an error
You can't specify target table 'TABLE1' for update in FROM clause.
Can someone tell me how to go about it?
UPDATE TABLE1
SET FIELD1 = concat('xyz', FIELD2)
where FIELD1 <> concat('xyz', FIELD2)
Is this what you mean?
UPDATE TABLE1
SET FIELD1 = CONCAT('xyz',`FIELD2`)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.