At 14:10 -0400 4/19/02, Andrew Kuebler wrote: >Maybe someone can help me here.. > >I'm inserting data with an AUTO_INCREMENT column and immediately after I >need to use that new number for a corresponding record in another table. >How am I able to extract that new number quickly? I could run a SELECT >query after the INSERT using the MAX command, but if at a busy time >another record is entered while the first record was being entered, it's >possibly I may get the wrong number. If there a way to use the INSERT >command and extract the new AUTO_INCREMENT all in one command? > >Any help is appreciated. > >Andrew
INSERT INTO tbl2 (id, ...) VALUES(LAST_INSERT_ID(), ...); --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php