FLOG51
asked on
MySQL Update Query using SELECT Statement
Hi
I am attempting to update a number of rows in a MySQL table with values from other rows within the same table and my attempts have failed. My attempt is below however it delivers the error message listed below the query.
UPDATE `Table` set `field_value` =
(SELECT `field_value` FROM `Table` WHERE `field_name` = 'xyz')
WHERE `field_name` = 'abc'
#1093 - You can't specify target table 'Table' for update in FROM clause
Basically I am attempting to use the Select Query to create the variable to use in the update Query.
Is this at all possible?
FLOG51
I am attempting to update a number of rows in a MySQL table with values from other rows within the same table and my attempts have failed. My attempt is below however it delivers the error message listed below the query.
UPDATE `Table` set `field_value` =
(SELECT `field_value` FROM `Table` WHERE `field_name` = 'xyz')
WHERE `field_name` = 'abc'
#1093 - You can't specify target table 'Table' for update in FROM clause
Basically I am attempting to use the Select Query to create the variable to use in the update Query.
Is this at all possible?
FLOG51
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the attempted help guys, as 'a_b' has stated this is possible from multiple tables but not from one.
ASKER
Am I correct in assuming that you have used two tables in this query i.e. "src" and "tab"
I am only using one table which has the data I wish to use to update values in the same Table.
Thanks
FLOG51