0

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

$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");
4

2 回答 2

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");

你不能放两个 where 子句

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

于 2012-12-31T08:17:33.450 回答
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");
于 2012-12-31T08:17:50.627 回答