List:MySQL on Win32« Previous MessageNext Message »
From:Paul DuBois Date:December 3 1999 12:46pm
Subject:Re: last_insert_id()
View as plain text  
At 1:00 AM -0600 12/3/99, Brian Dietrich wrote:
>Hello.  I was hoping someone could answer my question regarding the
>last_insert_id in MySql.  I am using autoincrement and I insert a row in one
>statement.  The next statement is a select using last_insert_id to obtain
>the autoincrement id.  I think this is a bad idea in a high-volume
>transactional system--or does MySql control this through the connection
>thread.  That is, I am worried about pulling back someone elses id in my
>last_insert_id select--someone who did an insert between the time I issued
>my insert and my select on last id.  Do I need to worry about this?  I
>looked at locking, but that does not appear to be a pretty option.    Any
>help would be greatly appreciated.

The last insert id is maintained on a per-client basis.  You cannot
get someone else's id.

Paul DuBois, paul@stripped
last_insert_id()Brian Dietrich3 Dec
  • Re: last_insert_id()Paul DuBois3 Dec
    • RE: last_insert_id()Brian Dietrich3 Dec
      • RE: last_insert_id()Paul DuBois3 Dec