Multiple MySQL Commands in mysql_query

admin

Administrator
Staff member
In MySQL, at the command line, I can enter multiple commands separated by a semi-colon. For example:

mysql> DELETE FROM abc;DELETE FROM xyz;

I've attempted to do that from PHP:
$query = "DELETE FROM abc;DELETE FROM xyz";
mysql_query($query) or die("Error -Cannot delete records");

When I attempt to execute this, the mysql_query() fails. Although the PHP manual does not address multiple mysql commands, it does mention that the query should not end with a semi-colon.

Is there a method to submit multiple mysql commands in a single mysql_query()?

thanks

rick

p.s. I'm using the above DELETE statements for illustration only.
 
Back
Top