更新时间:2023-02-05 09:07:04
您应该像这样通过联接进行更新
You should just being doing the update across a join like this
UPDATE
t1 INNER JOIN t2 ON t1.variant_id = t2.variant_id
SET t1.product_code = t2.value
WHERE t2.key_id = 10
AND t2.value IS NOT NULL
在这种情况下,无需担心空值,因为内部联接只会选择两个表中都存在variant_id的行.
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.