List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:January 13 2000 2:24am
Subject:Re: how to get the id of a newly inserted record???
View as plain text  
At 5:35 PM -0800 2000-01-12, jim@work wrote:
>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.

-- 
Paul DuBois, paul@stripped
Thread
how to get the id of a newly inserted record???jim@work13 Jan
  • Re: how to get the id of a newly inserted record???Paul DuBois13 Jan
    • RE: how to get the id of a newly inserted record???Nicolas Prade13 Jan
  • Re: how to get the id of a newly inserted record???Jamie Le Tual13 Jan
Re: how to get the id of a newly inserted record???Paul DuBois13 Jan