On Wed, 12 Nov 2003, Dan Anderson wrote:
> If I insert a row into mySQL with an indexed auto incrementing column,
> id, how do I get the id of the last inserted row?
>
For right now, you do this:
$insertid = $dbh->{'mysql_insertid'};
However, In the next version of DBD::mysql you will be able
: How do I get the row id of the last insert?
> By the way, this isn't the place to ask that question.
Sorry, PHP has a function to get the last row id. Didn't realize I had
to use SQL. That explains why my search found nothing. :-)
Thanks again,
Dan
> By the way, this isn't the place to ask that question.
Sorry, PHP has a function to get the last row id. Didn't realize I had
to use SQL. That explains why my search found nothing. :-)
Thanks again,
Dan
Dan Anderson said:
> If I insert a row into mySQL with an indexed auto incrementing column,
> id, how do I get the id of the last inserted row?
Use the LAST_INSERT_ID() function.
Or, see these pages:
http://www.mysql.com/doc/en/Getting_unique_ID.html
http://www.mysql.com/doc/en/mysql_insert_id.ht
If I insert a row into mySQL with an indexed auto incrementing column,
id, how do I get the id of the last inserted row?
Thanks in advance,
Dan