oracle使用instr或like方法判断是否包含字符串

Kelli ·
更新时间:2024-09-20
· 850 次阅读

首先想到的就是contains,contains用法如下:

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

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

好在我们还有另外一个办法,那就是使用instr,instr的用法如下:

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

另外,还有个笨办法,那就是使用like,说到这里大家应该知道怎么做了吧:

select * from students where address like '%beijing%' 您可能感兴趣的文章:oracle正则表达式regexp_like的用法详解Oracle中Like与Instr模糊查询性能大比拼oracle sql语言模糊查询--通配符like的使用教程详解Oracle如何实现like多个值的查询



LIKE 字符串 instr Oracle 字符

需要 登录 后方可回复, 如果你还没有账号请 注册新账号