multiple table inserts
5 answers - 264 bytes -

hi
the mysql docs don't seem to allow this but i'll ask.
is there a way to accomplish:
insert into cat,dog (cat.x,dog.y) values (1,2)
allowing me to essentially insert items into multiple tables
simultaneously
thanks
No.1 | | 408 bytes |
| 
Tue, 2006-08-15 at 07:56 -0700, bruce wrote:
hi
the mysql docs don't seem to allow this but i'll ask.
is there a way to accomplish:
insert into cat,dog (cat.x,dog.y) values (1,2)
allowing me to essentially insert items into multiple tables
simultaneously
If your using version 5 you can create a view accross the tables and
insert into that.
mark
No.2 | | 1433 bytes |
| 
Hell Bruce
Yes ,Here is the solution to insert the values from multiple table into a
table . We can achieve this by using the JINs(INNER JIN,LEFT JIN,RIGHT
JIN, join)
Consider the tables Animal,Feed and Animalfeed
Structure of the animal table
Id
name
variety
Structure of the feed table
id
Feed
Structure of animal table
id
Name
feed
I wan to update the table Animalfeed from tables Animal and Feed
INSERT INT Animalfeed SELECT a.id,a.name,b.feed FRM Animal a,feed b
WHERE a.id=b.id
Note:
1.Column of animalfeed table and SELECT QUERY must be SAME Datatype
2.If you want to insert the name and feed details into animalfeed table .
The query must be follow below synatx
INSERT INT Animalfeed(name,feed) SELECT a.name,b.feed from Animal a,feed b
WHERE a.id=b.id
Thanks
Visolve DB TEAM.
Message
From: "bruce" <bedouglas (AT) earthlink (DOT) net>
To: <mysql (AT) lists (DOT) mysql.com>
Sent: Tuesday, August 15, 2006 8:26 PM
Subject: multiple table inserts
hi
the mysql docs don't seem to allow this but i'll ask.
is there a way to accomplish:
insert into cat,dog (cat.x,dog.y) values (1,2)
allowing me to essentially insert items into multiple tables
simultaneously
thanks
>
>
>
No.3 | | 720 bytes |
| 
Hi Bruce
U can you mysql_insert_id function to insert values into multiple tables.
Please refer to for more details.
It also illustrates with examples.
Thanks
Visolve DB Team
Message
From: "bruce" <bedouglas (AT) earthlink (DOT) net>
To: <mysql (AT) lists (DOT) mysql.com>
Sent: Tuesday, August 15, 2006 7:56 AM
Subject: multiple table inserts
hi
the mysql docs don't seem to allow this but i'll ask.
is there a way to accomplish:
insert into cat,dog (cat.x,dog.y) values (1,2)
allowing me to essentially insert items into multiple tables
simultaneously
thanks
>
>
>
No.4 | | 783 bytes |
| 
Bruce,
why do you want to do that at all?
If you need to add values to several tables either at once or (in case
of an error) not at all, you should use transactions.
Fred
8/15/06, bruce <bedouglas (AT) earthlink (DOT) netwrote:
Message
From: "bruce" <bedouglas (AT) earthlink (DOT) net>
To: <mysql (AT) lists (DOT) mysql.com>
Sent: Tuesday, August 15, 2006 7:56 AM
Subject: multiple table inserts
--
hi
the mysql docs don't seem to allow this but i'll ask.
is there a way to accomplish:
insert into cat,dog (cat.x,dog.y) values (1,2)
allowing me to essentially insert items into multiple tables
simultaneously
thanks
>
>
>
No.5 | | 2116 bytes |
| 
Hi Bruce
What Fred said is true. transactions will help you.
Regards
Visolve DB Team
Message
From: "Frederic Wenzel" <fred (AT) osuosl (DOT) org>
To: <bedouglas (AT) earthlink (DOT) net>
Cc: "Visolve DB Team" <mysql_support (AT) visolve (DOT) com>; <mysql (AT) lists (DOT) mysql.com>
Sent: Tuesday, August 15, 2006 1:01 PM
Subject: Re: multiple table inserts
Bruce,
why do you want to do that at all?
If you need to add values to several tables either at once or (in case
of an error) not at all, you should use transactions.
Fred
--
8/15/06, bruce <bedouglas (AT) earthlink (DOT) netwrote:
>Message
>From: "bruce" <bedouglas (AT) earthlink (DOT) net>
>To: <mysql (AT) lists (DOT) mysql.com>
>Sent: Tuesday, August 15, 2006 7:56 AM
>Subject: multiple table inserts
>>
>>
>hi
>>
>the mysql docs don't seem to allow this but i'll ask.
>>
>is there a way to accomplish:
>>
>insert into cat,dog (cat.x,dog.y) values (1,2)
>>
>allowing me to essentially insert items into multiple tables
>simultaneously
>>
>thanks
>>
>>
>>
>--
>MySQL General Mailing List
>For list archives: http://lists.mysql.com/mysql
>To unsubscribe:
>@visolve.com
>>
>>
>>
>>
>--
>MySQL General Mailing List
>For list archives: http://lists.mysql.com/mysql
>To unsubscribe: @afip.gov.ar
>>
>>
>--
>MySQL General Mailing List
>For list archives: http://lists.mysql.com/mysql
>To unsubscribe: @gmail.com
>>
>>
>