我必须用一个由 3 个表的连接返回的值来更新一个字段。
例子:
select im.itemid ,im.sku as iSku ,gm.SKU as GSKU ,mm.ManufacturerId as ManuId ,mm.ManufacturerName ,im.mf_item_number ,mm.ManufacturerID from 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。
mf_item_number
item_master
如何在 MS SQL Server 中执行此操作?
UPDATE im SET mf_item_number = gm.SKU –etc FROM item_master im JOIN group_master gm ON im.sku = gm.sku JOIN Manufacturer_Master mm ON gm.ManufacturerID = mm.ManufacturerID WHERE im.mf_item_number like ‘STA%’ AND gm.manufacturerID = 34