How can I do an UPDATE statement with JOIN in SQL Server?

前端 未结 16 1241
名媛妹妹
名媛妹妹 2020-11-21 11:51

I need to update this table in SQL Server with data from its \'parent\' table, see below:

Table: sale

id (int)
udid         


        
16条回答
  •  终归单人心
    2020-11-21 12:09

    Another example why SQL isn't really portable.

    For MySQL it would be:

    update ud, sale
    set ud.assid = sale.assid
    where sale.udid = ud.id;
    

    For more info read multiple table update: http://dev.mysql.com/doc/refman/5.0/en/update.html

    UPDATE [LOW_PRIORITY] [IGNORE] table_references
        SET col_name1={expr1|DEFAULT} [, col_name2={expr2|DEFAULT}] ...
        [WHERE where_condition]
    

提交回复
热议问题