Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SELECTing the most recent auto_increment value

Status
Not open for further replies.

jimoblak

Instructor
Oct 23, 2001
3,620
US
I have a PHP script that INSERTs a new record with a key called 'ID'. The key is an auto_increment field. After the INSERT is performed, I would like to offer the web visitor the opportunity to modify or add to the record - - so I need to pass the ID value on to the next operation. Is there a simple trick to SELECT or obtain the ID that was just INSERTed so that more operations can be performed?

Should I simply
SELECT ID from mytable ORDER BY ID DESC LIMIT 0, 1
to get the most recent ID key or is there a better way to do this?

- - picklefish - -
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top