List:General Discussion« Previous MessageNext Message »
From:Martin Ramsch Date:August 15 1999 3:31am
Subject:Re: LAST_INSERT_ID()
View as plain text  
On Sat, 1999-08-14 23:13:47 -0400,
Jennifer <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?

None of both. :)

Quoting chapter "7.3.12 Miscellaneous functions" of the MySQL manual:

| LAST_INSERT_ID([expr]) 
|   [...]
|   The last ID that was generated is maintained in the server on a
|   per-connection basis. It will not be changed by another client.
So actually it's neither db nor table bound, but is to be understood
quite literal as the id, which has been automatically generated for
an AUTO_INCREMENT column last of all on the connection.

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


Martin Ramsch <m.ramsch@stripped> <URL: >
PGP KeyID=0xE8EF4F75 FiPr=52 44 5E F3 B0 B1 38 26  E4 EC 80 58 7B 31 3A D7
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