mysql等价于匹配时合并

qacovj5a  于 2021-06-20  发布在  Mysql
关注(0)|答案(1)|浏览(201)

我有以下ms sql查询:

MERGE drivessold as T USING specs as S ON
    drivessold.SKU = specs.SKU_num
    WHEN MATCHED THEN
    UPDATE SET 
    drivessold.color = specs.color, 
    drivessold.speed = specs.speed;

如何在mysql中执行类似的查询?
注意:sku和sku\ num不是表中的键(这是唯一的)。

rsaldnfx

rsaldnfx1#

在mysql中,这个操作需要join

UPDATE drivessold 
JOIN specs ON drivessold.SKU = specs.SKU_num
SET drivessold.color = specs.color, 
drivessold.speed = specs.speed;

相关问题