I am trying to update a set of rows which needs to be filtered by a JOIN to another table but which will not be doing the actual update.
Example:
The table to be update is called t2 It has a master table called t1. The actual rows to be updated are the rows from t2 where the status on t1 is ACTIVE. The actual field to be updated is called t2.t3_field which will be updated from table t3.
UPDATE t2
JOIN t1
ON t1.id = t2.t1_id
SET t3_field= t3.id
FROM t3
WHERE t3.old_id = t2.old_third_table_id
AND t1.status = 'ACTIVE';
This code does not work. Is there an easy way to achieve this?
Thanks for any help.
Dov