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

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

    No need for so long Mysql code. In PHP, query should look something like this:

    $updateQuery = mysql_query("UPDATE table_name SET row='value' WHERE id='$id'") or die ('Error');
    $lastUpdatedId = mysql_insert_id();
    

提交回复
热议问题