在mysql中为php执行多个sql删除查询 [英] Execute multiple sql delete query in mysql for php
本文介绍了在mysql中为php执行多个sql删除查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
由于某种原因,我想使用php mysql查询功能删除表中的某些记录.这是我写的
For some reason, i want to delete some of records in my table using php mysql query function. Here's what i've write
$sql = "delete from progress where first_date='2010-01-01' and last_date='2010-01-31';
delete from progress where first_date='2010-02-01' and last_date='2010-02-28';
delete from progress where first_date='2010-03-01' and last_date='2010-02-31';
delete from progress where first_date='2010-04-01' and last_date='2010-02-30';
delete from progress where first_date='2010-05-01' and last_date='2010-02-31';";
if(!mysql_query($sql)) echo "Error deleting records";
这正是我得到的,删除记录时出错".但是,当使用mysql_error()对其进行跟踪时,则根本没有用.有人知道如何处理吗?谢谢之前
Thats exactly what i get, "Error deleting records". However when itrace it using mysql_error() , its no use after all. Anyone know how to handle this? Thank's before
推荐答案
mysql_query()出于安全原因无法执行多个语句.
mysql_query() can't execute multiple statements for security reasons.
使用mysqli_multi_query()或多次调用mysql_query().
use mysqli_multi_query() or call mysql_query() many times.
这篇关于在mysql中为php执行多个sql删除查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文