Hi, Andrew,

To get the auto_increment value, simply execute
select last_insert_id()
after insert statement


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
>
>
>---------------------------------------------------------------------
>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
>
>
>  
>




---------------------------------------------------------------------
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

Reply via email to