Update multiple rows using select statement

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

    None of above answers worked for me in MySQL, the following query worked though:

    UPDATE
        Table1 t1
        JOIN
        Table2 t2 ON t1.ID=t2.ID 
    SET
        t1.value =t2.value
    WHERE
        ...
    

提交回复
热议问题