Update multiple rows using select statement

前端 未结 5 1844
鱼传尺愫
鱼传尺愫 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:11

    I have used this one on MySQL, MS Access and SQL Server. The id fields are the fields on wich the tables coincide, not necesarily the primary index.

    UPDATE DestTable INNER JOIN SourceTable ON DestTable.idField = SourceTable.idField SET DestTable.Field1 = SourceTable.Field1, DestTable.Field2 = SourceTable.Field2...
    

提交回复
热议问题