I have an update query that I need to run in MySQL and am having some trouble with it. I have spent the last hour researching SO for a solution, but couldn't find one that actually worked. I need to do the following:
UPDATE TABLE1 SET ID = (SELECT TABLE2.ID FROM TABLE2, TABLE1
WHERE TABLE1.NAME=TABLE2.NAME) WHERE TABLE1.ID IS NULL
I have been getting the Error Code: 1242. Subquery returns more than 1 row error. How can I modify my query to make it run successfully?
Basically, I need to fill in the blanks of all values of one column based on a condition, from another table. Please guide me on this issue. Thank you!