加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

oracle 数据库存 查找字符串函数 like instr

发布时间:2020-12-12 13:24:23 所属栏目:百科 来源:网络整理
导读:INSTR() 格式一:instr( string1,string2 ) 格式二:instr( string1,string2 [,start_position [,nth_appearance ] ] ) 解析:string2 的值要在string1中查找,是从start_position给出的数值(即:位置)开始在string1检索,检索第nth_appearance(几)次
INSTR()
格式一:instr( string1,string2 )
格式二:instr( string1,string2 [,start_position [,nth_appearance ] ] )
解析:string2 的值要在string1中查找,是从start_position给出的数值(即:位置)开始在string1检索,检索第nth_appearance(几)次出现string2。
例:
1 select instr(‘helloworld‘,‘l‘) from dual; --返回结果:3 默认第一次出现“l”的位置
2 select instr(‘helloworld‘,‘lo‘) from dual; --返回结果:4 即:在“lo”中,“l”开始出现的位置
3 select instr(‘helloworld‘,‘wo‘) from dual; --返回结果:6 即“w”开始出现的位置
4 select instr(‘helloworld‘,‘l‘,2,2) from dual; --返回结果:4 也就是说:在"helloworld"的第2(e)号位置开始,查找第二次出现的“l”的位置.
查询字串是否存在:
MySQL: select from tableName where name like ‘%helloworld%‘;Oracle:select from tableName where instr(name,‘helloworld‘)>0; --这两条语句的效果是一样的 select instr("helloworld","l") from dual; 结果为:3 #也就是“l”第一次出现的位置序号为3 select instr("helloworld","lo") from dual; 结果为:4 #也就是“lo”第一次出现的位置为4

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读