可能重复:
Mysql or/and precedence?
如果我有一个如下所示的查询:
SELECT *
FROM `users`
WHERE 'gen'='0' OR `gen`='1' AND `id` IN ('405','406','407',...),
它会返回用户的结果(gen ='0'或gen ='1')和(id
IN(...),还是其他一些结果?如果有,我可以加括号围绕条款分开?
感谢。
答案 0 :(得分:0)
尝试,
SELECT *
FROM `users`
WHERE `gen` IN (0, 1) AND
`id` IN ('405','406','407',...)
与
相同SELECT *
FROM `users`
WHERE (`gen`='0' OR `gen`='1') AND
`id` IN ('405','406','407',...)