当前位置:   article > 正文

oracle判断是否包含字符串_oracle 包含

oracle 包含

一、oracle判断是否包含字符串的方法

1、contains,contains用法如下:

select * from students where contains(address,  'beijing')
  • 1

但是,使用contains谓词有个条件,那就是列要建立索引,也就是说如果上面语句中students表的address列没有建立索引,那么就会报错。

2、instr,instr的用法如下:

select * from students where instr(address, 'beijing') > 0
  • 1

3、like,使用like:

select * from students where address like ‘%beijing%’  
  • 1

二、Oracle 查询字段不包含多个字符串方法

以数据列中不包含 YF、ZF、JD的字符串为例,

1:

select * from table  where  order_no not like '%YF%' and order_no not like '%ZF' and order_no not like '%JD%' 
  • 1

2、REGEXP_LIKE 可以实现包含多个,在前面加上 not 就可以实现不包含功能,方法如下:

 select * from table where not regexp_like(order_no,'YF|ZF|JD')   
  • 1

方法1总是比方法2快略快

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/949949
推荐阅读
相关标签
  

闽ICP备14008679号