I just wondering if there is a possibility to insert into the database two tables at once like,
$query = sprintf("INSERT INTO table ('tableid')values('somevaleu'),INSET INTO table1 ('table1id')values('somevalue')");
or I need to do it separately like,
$query1 = sprintf("INSERT INTO table ('tableid')values('somevaleu')");
$query2 = sprintf("INSET INTO table1 ('table1id')values('somevalue')");
Any suggestions?
If you are using the old mysql extension (
mysql_*functions), then you cannot issue multiple queries in one statement.From the manual1:
If you were using mysqli or pdo mysql then you can do multiple inserts in one query.
It would also be possible to insert multiple rows into the same table in one query using extended inserts, but not two different tables.