删除不区分大小写的mysql语句在php页面中不起作用

时间:2011-08-19 13:03:54

标签: php mysql

我使用此代码删除2表中的匹配tweeps,现在我的问题是当我执行php时它只删除1原始它应该删除5原始不敏感,我尝试在PMA中执行相同的sql语句并且其工作正常并删除所有匹配原始,任何线索为什么这发生在我执行php页面

<?php
include "dbconnect.php";
mysql_select_db("sdntweep_tweeps", $con);
mysql_query (" DELETE FROM tweeps WHERE screenname IN (SELECT LOWER (screenname) FROM non_sudanese ");
echo " done"
?>

2 个答案:

答案 0 :(得分:1)

你在子查询中错过了一个紧密的paren:

mysql_query (" DELETE FROM tweeps WHERE screenname IN ".
     "(SELECT LOWER (screenname) FROM non_sudanese ) "); //<-- at the end, 
      // it wasn't there before

如果您从驱动程序本身获得明智的错误消息,您会发现调试会更容易:

mysql_query ($yourStatement) or die(mysql_error());

答案 1 :(得分:1)

您的SQL语法出错:

mysql_query (" DELETE FROM tweeps WHERE screenname IN (SELECT LOWER (screenname) FROM non_sudanese ");

应该是

mysql_query (" DELETE FROM tweeps WHERE screenname IN (SELECT LOWER (screenname) FROM non_sudanese )");

注意额外的。)