MySQL UPDATE with SUBQUERY of same table

后端 未结 2 1738
温柔的废话
温柔的废话 2020-12-03 20:36

I am working with a complex MySQL database table that collects form data. I have simplified the layout in an example table called test below:



        
2条回答
  •  暖寄归人
    2020-12-03 21:36

    Aliasing should do the trick, if I'm understanding correctly:

    UPDATE test AS a
    JOIN test AS b ON a.id = b.id
        SET a.name = 'New Name'
    WHERE a.id = 104;
    

    Is this not working for you? UPDATE: This was tested and works on MySQL v5.6.

提交回复
热议问题