Reading Time: < 1 minute
When building a web application it can seem a bit tricky to get the value of the id (primary key) of the latest row inserted in a mysql table.
It is not that complicated.
The function LAST_INSERT_ID() can help you finding that. This function will return the latest auto-incremented value. No need to specify the table, it just takes the latest one.
SELECT LAST_INSERT_ID() ;
The next question is: what happens when I have many concurrent sessions on the same server? Will I get the latest inserted id from another user?