查询不等于多个值

时间:2012-12-31 08:15:45

标签: mysql

我有这方面的编码,有人可以帮助我使查询正确,我以为我有它但我只是收到一个查询错误
原始代码:

$q=$db->query("SELECT u.*,g.* FROM users u LEFT JOIN gangs g ON g.gangID=u.gang WHERE u.user_level != 2 $myf ORDER BY level DESC,userid ASC LIMIT 20");

我的编辑代码失败:

$q=$db->query("SELECT u.*,g.* FROM users u LEFT JOIN gangs g ON g.gangID=u.gang WHERE u.user_level != 2 || WHERE u.user_level !=0 $myf ORDER BY level DESC,userid ASC LIMIT 20");

2 个答案:

答案 0 :(得分:1)

使用此

$q=$db->query("SELECT u.*,g.* FROM users u LEFT JOIN gangs g ON g.gangID=u.gang WHERE u.user_level != 2 || u.user_level !=0 $myf ORDER BY level DESC,userid ASC LIMIT 20");

你不能把两个放在Clause

仅供参考:http://dev.mysql.com/doc/refman/5.0/en//select.html

答案 1 :(得分:0)

代替

$q=$db->query("SELECT u.*,g.* FROM users u LEFT JOIN gangs g ON g.gangID=u.gang WHERE u.user_level != 2 || WHERE u.user_level !=0 $myf ORDER BY level DESC,userid ASC LIMIT 20");

你应该,(删除第二位)

$q=$db->query("SELECT u.*,g.* FROM users u LEFT JOIN gangs g ON g.gangID=u.gang WHERE u.user_level != 2 || u.user_level !=0 $myf ORDER BY level DESC,userid ASC LIMIT 20");