我有两张桌子:
staticip有两列:ipstaticipid
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。

10-05 23:22