Sql server update multiple columns from another table

后端 未结 4 1692
情歌与酒
情歌与酒 2021-02-19 17:57

I have read lots of post about how to update multiple columns but still can\'t find right answer.

I have one table and I would like update this table from another table.

4条回答
  •  孤独总比滥情好
    2021-02-19 18:19

    You don't need to use a sub-query you can also simply do the following....

    Update t1 
    set t1.a  = t2.a
       ,t1.b  = t2.b
       ,t1.c  = t2.c
       ,t1.d  = t2.d
       .......
    from table1 t1
    JOIN table2 t2  ON t1.id = t2.id
    WHERE .......
    

提交回复
热议问题