模糊查询
模糊查询使用like关键字和通配符结合来实现,通配符具体含义如下:
% : 代表匹配0个字符、1个字符或多个字符
_ : 代表匹配有且只有1个字符
[] : 代表匹配范围内
[^] : 代表匹配不在范围内
--查询出姓刘的员工信息
select*from People where PeopleName like '刘%'
--查询出名字含有‘尚’的员工信息
select*from People where PeopleName like '%尚%'
--查询出名字含有‘尚’或者含有‘史’的员工信息
select*from People where
PeopleName like '%尚%' or PeopleName like '%史%'
--查询出姓刘且名字是2个字的员工信息
select*from People where PeopleName like '刘_'
select*from People where
subString(PeopleName,1,1)='刘' and len(PeopleName)=2 --subString(字符串,开始字符位数,查找的位数)
--查询最后一个字为香且名字为3个字的员工信息
select*from People where PeopleName like '__香'
select*from People where
subString(PeopleName,3,1)='香' and len(PeopleName)=3
--查询电话号前三位为187的员工信息
select*from People where PeoplePhone like '187%'
--查询电话号码前3位为187,第4位是3或者4,最后一个号码是8
select*from People where
PeoplePhone like '187[3,4]%8'
--查询电话号码前3位为187,第4位在2-5之间,最后一个号码不是2和3
select*from People where
PeoplePhone like '187[2,3,4,5]%[^2,3]'
select*from People where
PeoplePhone like '187[2-5]%[^2,3]'
标签:06,like,People,--,模糊,查询,PeopleName,where,select
From: https://www.cnblogs.com/Starry-blog/p/16797309.html