List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:April 28 2003 12:17pm
Subject:Re: INSERT in 2 tables at the same time
View as plain text  
At 11:46 +0200 4/28/03, Grégoire Dubois wrote:
>Hi all,
>
>I have a table "company" and a table "admin"...
>
>company
>admin_ID INT (reference to an admin)
>
>admin
>ID INT AUTO_INCREMENT
>
>Is it possible to create a company and an admin in a single INSERT,

No.  But you can use an AUTO_INCREMENT column in the admin_ID of the
company table. Then use LAST_INSERT_ID() to get the id for the admin
table.

This article shows how to do it:

http://www.onlamp.com/pub/a/onlamp/excerpt/mysqlckbk/index2.html

>  and make also the admin_ID of the company be the ID of the admin.
>Make the admin_ID of the company be the ID of the admin is very 
>important for me !
>
>Thank you very much for your Help.
>
>Greg.


-- 
Paul DuBois
http://www.kitebird.com/
sql, query
Thread
INSERT in 2 tables at the same timeGrégoire Dubois28 Apr
  • Re: INSERT in 2 tables at the same timePaul DuBois28 Apr
    • Re: INSERT in 2 tables at the same timeGrégoire Dubois28 Apr