The syntax for cross-table update in MySQL is somewhat different than T-SQL. Personally, the way it’s done in MySQL makes more sense.
MySQL:
MySQL:
UPDATE table1 t1 JOIN table2 t2 ON t1.id = t2.idT-SQL:
SET t1.col1 = t2.col2, t1.col2 = t2.col2
WHERE t2.col2 = 1 AND t1.col1 IS NULL;
UPDATE table1
SET col1 = t2.col1, col2 = t2.col2
FROM table1 t1 JOIN table2 t2 ON t1.id = t2.id
WHERE t2.col2 = 1 AND t1.col1 IS NULL;