6、模糊查询--通配
 模糊查询-通配符

 

    %  : 任意0个或多个字符
    select * from custbaseinfo where  idaddr like '%安徽%'         --idaddr是安徽的

 

    _  :下划线_替代任意单个字符
     SELECT * FROM fundinfo WHERE   fundid like  '_0%'            --fundid字段第二个字母是0的fundinfo数据

 

    [A-F]:字符是在A到F之间的任意字符 (A B C D E F)  ---与正则表达式的规则一致
    select *from custbaseinfo where custname like '_[A-F]%'   --custname中第二个字符是在A B C D E F中的任意字符
    select * from fundinfo where fundid like '[2-3]%'     --fundid字段的第一个字符是2 、3中任意一个字符都行

    

    [^A-F]:字符是不在A到F之间的任意字符 (A B C D E F)---与正则表达式规则一致
    select *from custbaseinfo where custname like '_[^A-F]%'   --custname中第二个字符是在A B C D E F中之外的任意字符
    select * from fundinfo where fundid like '[^2-3]%'     --fundid字段的第一个字符是2 、3中之外的任意字符

    

    【A,F】:字符是A或者F    --与正则表达式规则一致
 
 
    特殊说明:
 
    因为%  、 _ 是属于特殊字符,有特殊含义,如果要查询含有这些字符的字段,需要使用反斜杠\进行转义
    select * from customer where custname like '%\%%'    ESCAPE '\'             --escape '\'表示反斜杠作为转义字符

 

相关文章:

  • 2021-06-30
  • 2022-12-23
  • 2021-08-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-13
  • 2021-10-21
猜你喜欢
  • 2022-02-10
  • 2022-02-24
  • 2022-12-23
  • 2021-07-19
  • 2021-05-04
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案