---模糊查询---------
--查询姓刘的员工信息
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 PeopleName like '刘%' and len(PeopleName)=2
--查询名字最后一个字为"香",名字3个字的员工信息
select * from People
where PeopleName like '%香' and len(PeopleName)=3
select * from People
where PeopleName like '__香'
--查询出电话号码开头为138的员工信息
select * from People
where PeoplePhone like '138%'
--查询出电话号码开头为138的,第4位是7或者8,最后一个号码是5,员工信息
select * from People
where PeoplePhone like '138[7,8]%5'
--查询出电话号码开头为138的,第4位是2-5之间的数字,最后一个不是2和3
select * from People
where PeoplePhone like '138[2-5]%[^2,3]'
SQL sever数据库----模糊查询
最新推荐文章于 2024-08-25 20:13:45 发布