SQL update query using joins

后端 未结 11 1835
天涯浪人
天涯浪人 2020-11-22 01:15

I have to update a field with a value which is returned by a join of 3 tables.

Example:

select
    im.itemid
    ,im.sku as iSku
    ,gm.SKU as GSKU         


        
11条回答
  •  走了就别回头了
    2020-11-22 01:35

    You can use the following query:

    UPDATE im
    SET mf_item_number = (some value) 
    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    `sql`
    

提交回复
热议问题