Basically what I want to do is copy the value of a column from one table to another column in another table.
The query I am using is:
UPDATE t1
SET product_code =
(SELECT `value` FROM t2 WHERE t2.variant_id = t1.variant_id AND key_id = 10);
Which is working fine, but there is a mismatch in columns,
so I need to add in a clause which will only do the update on that row, if the subquery does not return null.
How can I do this?
You should just being doing the update across a join like this
There is no need to worry about nulls in that case as the inner join will only select rows where the variant_id exists in both tables.