Update multiple rows using select statement

前端 未结 5 1855
鱼传尺愫
鱼传尺愫 2021-01-04 00:38

I have these tables and values:

Table1
------------------------
ID | Value
------------------------
2 | asdf
4 | fdsa
5 | aaaa


Table2
---------------------         


        
5条回答
  •  梦谈多话
    2021-01-04 01:17

    You can use alias to improve the query:

    UPDATE t1
       SET t1.Value = t2.Value
      FROM table1 AS t1
             INNER JOIN 
           table2 AS t2
             ON t1.ID = t2.ID
    

提交回复
热议问题