General Question

fuze's avatar

How do I do a MySQL Insert statement into 2 different tables?

Asked by fuze (17points) January 28th, 2007
For instance, I want to do this: ------------- table A ------------- red blue ------------- table B ------------- apple blueberry and I want to insert Orange into table A and Carrot into table B.
Observing members: 0 Composing members: 0

5 Answers

samkusnetz's avatar
sounds to me like two separate insert statements... or maybe i don't understand the question...
fuze's avatar
yeah, I ended up doing it with two seperate statements....just thought that maybe I could simplify it
segdeha's avatar

I thought there was a way to do this, but I think I was thinking of doing updates to multiple tables in one statement. After a quick search on Google, it seems it isn't possible to insert into multiple tables in one statement. But, this article offers a tip for simplifying the process using mysql_insert_id:

http://www.desilva.biz/mysql/insertid.html

twilliams's avatar

Shouldn't be possible since this would not be ACID:

http://en.wikipedia.org/wiki/ACID

gsiener's avatar

Sounds like a job for a stored procedure.

Answer this question

Login

or

Join

to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
or
Knowledge Networking @ Fluther