我有两张桌子:staticip
有两列:ip
,staticipid
rm_users
有许多列,其中之一是staticipcpe
我想在staticip
表中找到staticipid='2'
和ip
不等于staticipcpe
的行。
我尝试了下面的sql语句,但它不起作用。
$sqls="select s.ip, s.staticipid from staticip s
where s.staticipid='2' and not exists
(select u.staticipcpe from rm_users u
where u.staticipcpe=s.ip";
我有以下信息
"Warning: mysql_result(): supplied argument is not a valid MySQL result resource"
最佳答案
在其他可能的问题中,缺少右括号:
$sqls="select s.ip, s.staticipid from staticip s
where s.staticipid='2' and not exists
(select u.staticipcpe from rm_users u
where u.staticipcpe=s.ip)";
还有,the mysql_* functions are deprecated。使用MySQLi或PDO。