Page 1 of 1

INSERT problem. URGENT !!!

Posted: Sun Oct 12, 2003 2:44 pm
by liviu
How can i insert a row in more than one table in one shot ?
something like:

insert into table1.table2 (col1,col2,col3) values (val1,val2,val3);

is this posible :?:

Posted: Sun Oct 12, 2003 2:53 pm
by devork
yep you can do
$query="insert into table1(cols) values (......); insert into table2(cols) values(.....);"
just place the semicolor after every query completion..

Posted: Sun Oct 12, 2003 7:38 pm
by Stoneguard
While you can do this, you are still preforming multiple queries. You cannot actually write one query with one result to insert against multiple tables unless it is into a View (which are not available in MySQL). Personally I would rather see the return result from each insert than potentially have a fail happen and miss it.