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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值