MySQL: Get ID of the Last Updated Row

In this post, I demonstrate to get last updated ID of the last updated row in MySQL.
Whenever we are not updating row base on Primary key and updating row base of any other column data like: date, Name, at that time we require last updated id of the last updated row.

We should write update query such a way that we can get a last updated ID at the same time of update.
Here, I have provided different two way two ways to get a last updated ID of the last updated row.

Let’s first create a table with sample data.

First script to get a last updated ID:
Get all last updated ID when more than one row updates:
Second script using LAST_INSERT_ID():
Before this, please execute the insert script again.
Anvesh Patel

Leave a Reply

1 Comment on "MySQL: Get ID of the Last Updated Row"

Notify of
avatar
Sort by:   newest | oldest | most voted
desmond
Guest

Thanks Anvesh, You helped me lot. I am following you and interested in your articles and collections of DBA script.

wpDiscuz