When inserting a record using PHP into a MySQL database, how can you return a value from an autonumber field after the insert. I don't want to requery.
Is this possible?
The mysql_insert_id function should handle this... right after your insert query is run...
$x = mysql_insert_id($connection);
$x will contain the last inserted autonumber id. For more info, check http://www.php.net/manual/en/function.mysql-insert-id.php
Yes - you need perform this query after the insert
select LAST_INSERT_ID() as ID