为什么将我的SQL查询组合成一个不起作用? [重复]

This question already has an answer here:

These two PHP MySQL queries work.

mysql_query("DELETE FROM videos WHERE id='10';");
mysql_query("DELETE FROM comments WHERE videoId='10';");

This single query fails due to a MySQL syntax error pertinent to the latter DELETE operation.

mysql_query("DELETE FROM videos WHERE id='10';DELETE FROM comments WHERE videoId='10';");

I've stared hard and can't see the syntax error. What is it?

</div>

You cannot execute multiple queries with mysql_query. If you really want to (security risk!), use mysql_multi_query. (And you should use the newer mysqli_* functions). It's a good idea two embed those two calls in a transaction.

But this looks a lot like you really want to define foreign key constraints. I highly recommend them, if you are already using InnoDB.

Multiples queries are not supported in this function.

http://php.net/manual/en/function.mysql-query.php