Hi Rick,
See the following from the MySQL Reference Manual:
--------------------------------------------------------------------------------
You can retrieve the most recent AUTO_INCREMENT value with the LAST_INSERT_ID() SQL function or the mysql_insert_id() C API function. These functions are connection-specific, so their return value is not affected by another connection also doing inserts.
Note: For a multiple-row insert, LAST_INSERT_ID()/mysql_insert_id() will actually return the AUTO_INCREMENT key from the first of the inserted rows. This allows multiple-row inserts to be reproduced correctly on other servers in a replication setup.
-------------------------------------------------------------------------------
See
http://dev.mysql.com/doc/mysql/en/example-AUTO_INCREMENT.html for more details.
As you will see, the values are connection specific, so they should return the last auto increment value from your session. The functions behave slighly differently with regard to return values for inserts that don't use NULL to generate an auto-increment (e.g. by inserting a specific value into the auto-increment column)
See
http://dev.mysql.com/doc/mysql/en/mysql_insert_id.html for details on how the native MySQL and C API functions differ.
Which version of MySQL are you using, if it's 4.x + then you might be able to do the whole thing with a multiple table update statement, but it's a bit late in the day to get my head round it right now.
Cheers,
Nick
--
Nick Roper