where子句在('str1'、'str2'、'str3')中的行为很奇怪

ve7v8dk2  于 2021-06-24  发布在  Hive
关注(0)|答案(2)|浏览(414)

当我运行代码时

SELECT * FROM tbl
WHERE
date BETWEEN '20200520' and '20200520' 
and country_id in ('US','us','USA')

--and upper(country_id) in ('US''JP','IN','GB','CA')
and app_id in (1180,1233)
LIMIT 5

我得到的结果如下

但是,如果我在下面添加where子句,则不会返回任何数据。

SELECT * FROM
    tbl
WHERE
date BETWEEN '20200520' and '20200520' 
and country_id in ('US','us','USA')
and upper(country_id) in ('US''JP','IN','GB','CA')
and app_id in (1180,1233)
LIMIT 5

国家/地区id在('美国'和'美国')的记录还应该退回吗?这里怎么了?
提前谢谢。

smdncfj3

smdncfj31#

使用或代替and

SELECT * FROM
    tbl
WHERE
date BETWEEN '20200520' and '20200520' 
and (country_id in ('US','us','USA')
or upper(country_id) in ('US','JP','IN','GB','CA')
)
and app_id in (1180,1233)
LIMIT 5
fgw7neuy

fgw7neuy2#

你少了一个逗号。
和上(国家/地区id)in('us''jp','in','gb','ca')

相关问题