List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:August 15 1999 3:26am
Subject:Re: LAST_INSERT_ID()
View as plain text  
At 11:13 PM -0400 8/14/99, toxalot@stripped wrote:
>I understand that LAST_INSERT_ID() returns the value of the last
>auto_increment value, but is that for the whole db or is separate for each
>table?



LAST_INSERT_ID() returns the most recently automatically-generated
AUTO_INCRMENT value for the session (i.e., for the connection that
you have open to the server).  If you close the connection and then
open another one and call LAST_INSERT_ID(), you'll get back a 0.

>I want to insert a record and then tell the user what there id is.  Is
>LAST_INSERT_ID() what I should be using?


Yes, as long as you do so in the same connection as the one on
which you generated the record.

-- 
Paul DuBois, paul@stripped
Thread
LAST_INSERT_ID()toxalot15 Aug
  • Re: LAST_INSERT_ID()Paul DuBois15 Aug
    • Re: LAST_INSERT_ID()toxalot15 Aug
      • Re: LAST_INSERT_ID()Thimble Smith15 Aug
      • ezmlm-send: fatal...Paul DuBois15 Aug
        • Re: ezmlm-send: fatal...Darrell Shifflett15 Aug
          • Re: ezmlm-send: fatal...Darrell Shifflett15 Aug
        • Re: ezmlm-send: fatal...Martin Ramsch15 Aug
        • Re: ezmlm-send: fatal...Frederik Lindberg16 Aug
  • Re: LAST_INSERT_ID()Martin Ramsch15 Aug