Check the manual for last_insert_id().

Noel Wade wrote:

Hi All,

Say I have a table with an auto_increment field that is being used at the primary key.

When I insert a new record, is there any way to easily grab the primary key value for that new record? I had another unique field that I was originally going to use to do a select statement; but now that's been changed to a non-unique field.

Is there some way to easily snag the record that has just been inserted (or the primary key from this new record)?

Or is it easier and better to determine the auto_increment value BEFORE doing the insert (and manually specifying the value for the primary key in the insert statement)?

Thanks, take care,

--Noel







-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to