List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:October 31 2001 3:47am
Subject:Re: insert statement new trouble
View as plain text  
At 2:43 AM +0000 10/31/01, Curtis Gordon wrote:
>I have a query where I am inserting a record into a db, and would 
>like to have the primary key
>value returned, I have been reading and reading, but I can't seem to find
>any mention of this. I would think that this would be useful. Can anybody
>help?

You can't get the primary key value returned from the INSERT statement
itself.  But (assuming the key is an AUTO_INCREMENT column), you can
issue this query after the INSERT to get the value:

SELECT LAST_INSERT_ID()
Thread
insert statement new troubleCurtis Gordon31 Oct
  • Re: insert statement new troublePaul DuBois31 Oct