Spidy has asked for the wisdom of the Perl Monks concerning the following question:
In order to retrieve the ID number for something I've just inserted into a MySQL table, I've been using the following query:
"SELECT LAST_INSERT_ID() FROM table"
Which has been working well and fine while I'm testing, but I've been wondering: if there are a lot of simultaneous actions, and another row is inserted before the above statement is called, which ID is returned? Is it the ID for the last insert from that specific database connection, or is it the global last ID?
Thanks,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI/MySQL and LAST_INSERT_ID()
by ikegami (Patriarch) on Nov 07, 2006 at 17:54 UTC | |
|
Re: DBI/MySQL and LAST_INSERT_ID()
by perrin (Chancellor) on Nov 07, 2006 at 17:36 UTC | |
|
Re: DBI/MySQL and LAST_INSERT_ID()
by RandomWalk (Beadle) on Jan 05, 2008 at 22:13 UTC |