>div class="s-table-container">
id | topic_id | id |
---|---|---|
1 | 21 | null |
2 | null | 1 |
UPDATE table t1
JOIN table t2 ON t1.id = t2.id2 -- join 2 tables copies according to the relation
SET t2.topic_id = t1.topic_id -- copy the value into the column
WHERE t2.topic_id IS NULL; -- update only rows without the value in the column