List:General Discussion« Previous MessageNext Message »
From:Dan Nelson Date:April 18 2003 3:17pm
Subject:Re: last_insert_id() with multiple users
View as plain text  
In the last episode (Apr 19), Robert Mark Bram said:
> Howdy All!
> 
> This is not mine, but a comment I found in the manual that I would
> very much like to see answered.
> 
> How does the combination of auto_increment and last_insert_id() work in a
> concurrent situation:
> User1 inserts with auto_increment, and for some reason is delayed with the
> last_insert_id() call.
> User2 inserts with auto_increment.
> User2 calls last_insert_id()
> User1 finally calls last_insert_id()
> 
> Which id does User1 get?
> Which id does User2 get?
> 
> http://www.mysql.com/doc/en/example-AUTO_INCREMENT.html

http://www.mysql.com/doc/en/Miscellaneous_functions.html

   LAST_INSERT_ID([expr])
          Returns the last automatically generated value that was
          inserted into an AUTO_INCREMENT column. See section 8.1.3.130
          mysql_insert_id().

          The last ID that was generated is maintained in the server on a
          per-connection basis. It will not be changed by another client.

-- 
	Dan Nelson
	dnelson@stripped
Thread
last_insert_id() with multiple usersRobert Mark Bram18 Apr
  • Re: last_insert_id() with multiple users(Terry Riley)18 Apr
    • Re: last_insert_id() with multiple usersBernhard Döbler22 Apr
  • Re: last_insert_id() with multiple usersDan Nelson18 Apr