Hi I have two table one like this one: table1
and one like this: table2
I would like to update all the fields on the table2 column “newID” based on this rules: if (table2.ID = table1.ID_actual or table2.ID=table1.ID_old) then table2.newID = table1.newID How can I resolve this problem ?
Advertisement
Answer
You need a join of the 2 tables in the UPDATE
statement:
UPDATE table2 t2 INNER JOIN table1 t1 ON t2.ID IN (t1.ID_actual, t1.ID_old) SET t2.newID = t1.newID