一、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快略快

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐