List:General Discussion« Previous MessageNext Message »
From:mos Date:March 12 2010 3:36pm
Subject:Re: Nested inserts possible?
View as plain text  
Keith,
      You will need to reference the mysql_insert_id() function after 
adding the row to Table_One. Then use the value returned for the rest of 
the tables.

http://dev.mysql.com/doc/refman/5.1/en/getting-unique-id.html

Mike

At 08:48 AM 3/12/2010, you wrote:
>I have two tables and I have data to insert into both at the same time,
>but the second table depends on an ID that is auto created in the first
>table.  I'm not sure exactly how to accomplish this.
>
>Table_One
>
>Table_One_Index_ID
>Data_One
>Date_Two
>
>Table_Two
>
>Table_Two_Index_ID
>Table_One_Index_ID
>Data_Three
>Data_Four
>
>
>
>
>--
>MySQL General Mailing List
>For list archives: http://lists.mysql.com/mysql
>To unsubscribe:    http://lists.mysql.com/mysql?unsub=1

Thread
Nested inserts possible?Keith Clark12 Mar
  • Re: Nested inserts possible?mos12 Mar
  • Re: Nested inserts possible?Johan De Meersman12 Mar
Re: Nested inserts possible?Keith Clark12 Mar
  • RE: Nested inserts possible?Gavin Towey12 Mar