oracle判断是否包含字符串

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

1、contains,contains用法如下:

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

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

2、instr,instr的用法如下:

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

3、like,使用like:

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

二、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%' 

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

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

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

原文地址:https://www.cnblogs.com/lllini/p/11955215.html