SQL通配符

通配符包括以下几种:  

(1)% : 表示0个或多个字符      

(2)_ : 表示单个字符 (A_BC)

(3)[] : 代表范围内单个字符  [A-F] [2-9]

(4)[^] : 代表不在范围内单个字符  [^A-F] [^2-9]

 

语法格式:测试表达式  like  '通配符'

 

例: (1) select * from table where  姓名 like '张 %'

(2)select * from  yuesubiao where book_name like 'javac ! % %' escape '!'

(“ !”:用来区分要查找的字符中的“%”与通配符中的“%”。其中,前“%“号为字符,后”%“为通配符)

Escape 指定表示转义的字符,上文指定’!’为转义字符。

select * from yuesubiao where book_name book_name like 'kill !_%' escape '!'

(3) select * from 职工 where 职工号 + 仓库号 like ‘%3%’

等价于 select * from 职工 where 职工号 like ‘%3% or 仓库号 like ‘%3%’

原文地址:https://www.cnblogs.com/xieyuanzheng/p/5605308.html