当前位置:Gxlcms > 数据库问题 > oracle 数据库存 查找字符串函数 like instr

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

时间:2021-07-01 10:21:17 帮助过:2人阅读

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

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

标签:str   ring   tar   table   from   数值   ike   函数   解析   

人气教程排行