SQL update query using joins

后端 未结 11 1815
天涯浪人
天涯浪人 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:32

    You can specify additional tables used in determining how and what to update with the "FROM " clause in the UPDATE statement, like this:

    update item_master
    set mf_item_number = (some value)
    from 
       group_master as gm
       join Manufacturar_Master as mm ON ........
    where
     .... (your conditions here)
    

    In the WHERE clause, you need to provide the conditions and join operations to bind these tables together.

    Marc

提交回复
热议问题