How to get ID of the last updated row in MySQL?

后端 未结 12 2481
北海茫月
北海茫月 2020-11-22 08:10

How do I get the ID of the last updated row in MySQL using PHP?

12条回答
  •  半阙折子戏
    2020-11-22 08:44

    My solution is , first decide the "id" ( @uids ) with select command and after update this id with @uids .

    SET @uids := (SELECT id FROM table WHERE some = 0 LIMIT 1);
    UPDATE table SET col = 1 WHERE id = @uids;SELECT @uids;
    

    it worked on my project.

提交回复
热议问题