Web lists-archives.com

Re: How to get auto Increment ID of INSERT?




LAST_INSERT_ID() returns the latest ID for the current connection. As long as you yourself can guarantee that no other queries are executed using that connection, you're fine. If another record others is inserted using another connection, that connection will return a different LAST_INSERT_ID().

Best,

/ Carsten

On 08-10-2015 15:48, Richard Reina wrote:
If I insert a record into a table with an auto increment ID how can I get
that records ID value? I have read about SELECT LAST_INSERT_ID() statement,
however, do not two statements introduce the risk that another insert may
occur in the interum? Is there a full proof way of getting the ID of the
record that you have just inserted?

Thanks


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql