使用联接的SQL更新查询我必须用一个值更新一个字段,该值由3个表的联接返回。例子:select
im.itemid ,im.sku as iSku ,gm.SKU as GSKU ,mm.ManufacturerId as ManuId ,mm.ManufacturerName
,im.mf_item_number ,mm.ManufacturerIDfrom
item_master im, group_master gm, Manufacturer_Master mm
where
im.mf_item_number like 'STA%'
and im.sku=gm.sku and gm.ManufacturerID = mm.ManufacturerID and gm.manufacturerID=34我想更新mf_item_number表的字段值item_master在上述条件下加入的其他值。如何在MSSQLServer中做到这一点?
3 回答
幕布斯7119047
TA贡献1794条经验 获得超8个赞
UPDATE imSET mf_item_number = gm.SKU --etcFROM item_master imJOIN group_master gm ON im.sku = gm.sku JOIN Manufacturer_Master mm ON gm.ManufacturerID = mm.ManufacturerIDWHERE im.mf_item_number like 'STA%' AND gm.manufacturerID = 34
UPDATE
FROM
im
通用示例
UPDATE ASET foo = B.barFROM TableA AJOIN TableB B ON A.col1 = B.colxWHERE ...
慕容3067478
TA贡献1773条经验 获得超3个赞
FROM
UPDATE
UPDATE item_master im JOIN group_master gm ON im.sku=gm.sku JOIN Manufacturer_Master mm ON gm.ManufacturerID=mm.ManufacturerIDSET im.mf_item_number = gm.SKU --etcWHERE im.mf_item_number like 'STA%' AND gm.manufacturerID=34
添加回答
举报
0/150
提交
取消