MYSQL multiple inserts/updates question
Posted: Mon Oct 03, 2005 2:40 pm
I remember you can have multiple inserts/updates but forgot how do you do it.
if you have 2 SQL
$sql1="UPDATE table SET item=1 WHERE id=1";
$sql2="INSERT INTO table (item) VALUES ('1');
How do you make it into a string to run it once so its committed into the DB?
Then there is the other question, because there are 40,000 items to be either updated or inserted depending if they are new or existing. Would it be advisable to send a string of 40,000 items to mysql_query?
Which would be faster? doing each query as they come up or compile them together and doing it all at once?
NOTE: 90% of the queries should be INSERT.
Thanks in advance.
Mian
if you have 2 SQL
$sql1="UPDATE table SET item=1 WHERE id=1";
$sql2="INSERT INTO table (item) VALUES ('1');
How do you make it into a string to run it once so its committed into the DB?
Then there is the other question, because there are 40,000 items to be either updated or inserted depending if they are new or existing. Would it be advisable to send a string of 40,000 items to mysql_query?
Which would be faster? doing each query as they come up or compile them together and doing it all at once?
NOTE: 90% of the queries should be INSERT.
Thanks in advance.
Mian