使用 (反斜杠)在 HIVE hadoop 中查询



我需要查询具有类似值的列

列名称是位置:

c:usersabcdhello
c:usersxyabcdddhello
c:usersabcderhello

我需要准确查询值"abcd"

select * from table where locations like '%abcd'
select * from table where locations like '%\abcd\'
select * from table where locations like '%\\abcd\\'

最重要的是不起作用。

如果我像下面这样查询

select * 
from table 
where locations like '%abcd%'

它将获取所有结果,而不是确切的结果

c:usersabcdhello
c:usersxyabcdddhello
c:usersabcderhello

但我需要

正是这个'c:\users\abcd\hello'

这工作正常。

select locations from tablename where 
(instr(lower(locations),'\abcd\') IS NOT NULL) 
AND (instr(lower(locations),'\abcd\') != 0)

这只会获取

c:usersabcdhello

参考: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF#LanguageManualUDF-StringFunctions

最新更新