instr 语法
instr(filed,str)
返回str子字符串在filed字符串的第一次出现的位置,如果没有找到,则返回0。备注:位置是从1开始的。当instr(filed,str)=0时,表示子符串str不存在于字符串filed中,因此可以用来实现mysql中的模糊查询,与like用法类似。
select instr('abc','a') -- 1
select instr('abc','b') -- 2
select instr('abc','d') -- 0
case when instr(filed,'a') then 'a'
when instr(filed,'b') then 'b'
when instr(filed,'c') then 'c'
else '其他' end filed