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

后端 未结 12 2436
北海茫月
北海茫月 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:25

    SET @uids := "";
    UPDATE myf___ingtable
       SET id = id
       WHERE id < 5
      AND ( SELECT @uids := CONCAT_WS(',', CAST(id AS CHAR CHARACTER SET utf8), @uids) );
    SELECT @uids;
    

    I had to CAST the id (dunno why)... or I cannot get the @uids content (it was a blob) Btw many thanks for Pomyk answer!

提交回复
热议问题