I have a table with a standard auto numbered primary key, I was wondering if there's any way for MySQL to return the id number of the record it inserts after inserting it (if that made any sense) without running another query.
Thanks for your time.
Newbie MySQL Question
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
You can use mysql_insert_id() (it has to be run directly after the query):
or LAST_INSERT_ID().
Mac
Code: Select all
mysql_query("INSERT .... ");
$id = mysql_insert_id();Mac