zoukankan      html  css  js  c++  java
  • 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快略快

  • 相关阅读:
    char 转string
    博客,记忆的图谱。
    history
    openstack Icehouse发布
    数据库常用命令
    nagios
    screen
    openstack 流量控制
    sublime 3
    磁盘类型
  • 原文地址:https://www.cnblogs.com/lllini/p/11955215.html
Copyright © 2011-2022 走看看