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

前端 未结 16 1507
名媛妹妹
名媛妹妹 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:16

    PostgreSQL:

    CREATE TABLE ud (id integer, assid integer);
    CREATE TABLE sales (id integer, udid integer, assid integer);
    
    UPDATE ud
    SET assid = sales.assid
    FROM sales
    WHERE sales.id = ud.id;
    

提交回复
热议问题