ok, i'm sure i have missed this in previous discussions, and it
seems so elemetary (uh, ya) that i must have overlooked it in the
manual (albeit, it's huge).
when i insert a record into the database from PERL (using DBI), that
has an auto-increment primary key, how do i got about getting that
primary key value??
In SQL: SELECT LAST_INSERT_ID()
In DBI: $dbh->{mysql_insert_id}
In PHP: mysql_insert_id()
Of course, you can use the SQL statement in either DBI or PHP, too.
Hello,
just one precision/warning, from the doc:
" The most recently generated ID is maintained in the server on a
per-connection basis. It will not be changed by another client. It will not
even be changed if you update another AUTO_INCREMENT column with a non-magic
value (that is, a value that is not NULL and not 0). "
This means a little more work :-) for those of us
using only 1 connection for all the clients, for example
by setting up the connection in a Java servlet.