Forum Moderators: coopster

Message Too Old, No Replies

Running multiple MySQL queries with one call

         

erikcw

3:52 pm on Sep 3, 2005 (gmt 0)

10+ Year Member



Hi,

I've been trying to figure out how to run multiple MySQL queries with one database call. In phpMyAdmin, I can seperate sever queires with a ";", but mysql_query() doesn't seem to support this. (I get an error when trying to do it).

mysql_query("SELECT blah FROM tbl1; SELECT this FROM tbl2 WHERE x = '2'; INSERT INTO tbl1 VALUES (NULL,something)");

Any tips on how I can accomplish this would be great!

Thanks!
Erik

chriswragg

4:41 pm on Sep 3, 2005 (gmt 0)

10+ Year Member



Can you not just have each SQL Statement in a separate mysql_query()?

mysql_query("SELECT blah FROM tbl1; SELECT this FROM tbl2 WHERE x = '2'");
mysql_query("INSERT INTO tbl1 VALUES (NULL,something)");

JamShady

6:29 pm on Sep 3, 2005 (gmt 0)

10+ Year Member



phpMyAdmin actually performs the queries separately though. It takes the whole string, parses out individual statements, executes them, and displays results for the last query

coopster

8:15 pm on Sep 6, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Something similar came up not too long ago. You may want to check out the new extension mentioned by ergophobe and see it is something that will work for you.

Large inserts and updates [webmasterworld.com]