List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:October 1 2001 2:50am
Subject:Re: How To call mysql_insert_id
View as plain text  
At 6:45 PM -0500 9/30/01, Reuben D Budiardja wrote:
>Hi,
>I am a newbie in MySQL. I use an auto_increment to insert to one of the
>column. How do I get the value inserted?
>
>The documentation seems to suggest using mysql_insert_id() function. But when
>I tried to call it using
>Select mysql_insert_id()
>or
>Select mysql_insert_id() from TABLE_NAME

mysql_insert_id() is the C API function for obtaining that value.
Use LAST_INSERT_ID() instead:

SELECT LAST_INSERT_ID()

You don't want "SELECT LAST_INSERT_ID() from TABLE_NAME", probably.
That will give you the insert-id value once for each row in TABLE_NAME.

>
>gives me error. I tried to find something in the doc, but it does not really
>help.


http://www.mysql.com/doc/M/i/Miscellaneous_functions.html

>
>Please help.
>Thanks in advance.
>Reuben D. Budiardja


-- 
Paul DuBois, paul@stripped
Thread
How To call mysql_insert_idReuben D Budiardja1 Oct
  • RE: How To call mysql_insert_idDaniel Ouellet1 Oct
  • Re: How To call mysql_insert_idPaul DuBois1 Oct