我有一个非常简单的查询返回结果,我很确定不应该包含它。
CREATE TABLE hits
AS SELECT *
FROM deduped_table
WHERE Bank LIKE '%monex%' OR Bank LIKE '%cibanco%' OR Bank LIKE '%intercam%'
AND (Bank_Country = 'US' OR Bank_Country = 'United States');
当我查看点击表时,Bank_Country列的结果不是“美国”或“美国”。为什么呢?
答案 0 :(得分:4)
添加括号以显示SQL's precedence rules,您的查询为:
SELECT *
FROM deduped_table
WHERE Bank LIKE '%monex%'
OR Bank LIKE '%cibanco%'
OR (Bank LIKE '%intercam%' AND
(Bank_Country = 'US' OR Bank_Country = 'United States'));
答案 1 :(得分:3)
要完成@CL。答案,您的查询应该阅读
fun()