hive instr 函數

instr(string str, string substr)code

查找字符串str中子字符串substr出現的位置,若是查找失敗將返回0,若是任一參數爲Null將返回null,注意位置爲從1開始的xml

示例:若是在一個表裏面找出某些字段包含一些特殊字符的數據 如:ci

*
(
)
+
|
"
:
?
>
<
{
}
[
]
.
,字符串

則代碼以下string

select cid,
last_name,
first_name
from
contact.t_customer_contact_list_total
where day='2017-06-22'
and 
(
instr(first_name,'*')>0 or instr(last_name,'*')>0 or
instr(first_name,'(')>0 or instr(last_name,'(')>0  or
instr(first_name,')')>0 or instr(last_name,')')>0  or
instr(first_name,'_')>0 or instr(last_name,'_')>0 or
instr(first_name,'+')>0 or instr(last_name,'+')>0 or
instr(first_name,'"')>0 or instr(last_name,'"')>0 or
instr(first_name,':')>0 or instr(last_name,':')>0 or
instr(first_name,'?')>0 or instr(last_name,'?')>0 or
instr(first_name,'>')>0 or instr(last_name,'>')>0 or
instr(first_name,'<')>0 or instr(last_name,'<')>0 or
instr(first_name,'{')>0 or instr(last_name,'{')>0 or
instr(first_name,'}')>0 or instr(last_name,'}')>0 or
instr(first_name,'[')>0 or instr(last_name,'[')>0 or
instr(first_name,']')>0 or instr(last_name,']')>0 or
instr(first_name,'.')>0 or instr(last_name,'.')>0 
)
limit 10
;
相關文章
相關標籤/搜索