首页 > 其他 > 详细

BetWeen和模糊查询

时间:2014-04-07 06:25:34      阅读:829      评论:0      收藏:0      [点我收藏+]

--区分大小写性能比较低
select * from Students where Age >1 and Age <4
select * from Students where Age between 1 and 4--取出一到四的数据包含一和四(between在数据库有优化,性能比较好,高于上面的语句)

select * from Students where Age in(1,2,3)--查询出年龄包含1,2,3的数据
select * from Students where Name like ‘a%‘ --以a开头的后面不管有几个字符都可以匹配

select * from Students where Name like ‘_a%‘--第二个字符是a的,_表示一个任意字符
select * from Students where Name like ‘__a%‘ --前两个是任意字符,第三个是a字符的进行匹配
select * from Students where Name like ‘%[0-9]%‘--查询中间任何位置有数字的
select * from Students where Name like ‘%[a-z]%‘--查出中间任何位置有字母的
select * from Students where Name like ‘%[0-9a-z]%‘--查询中间任何位置有数字或字母的
select * from Students where Name like ‘%[^0-9]%‘ --查询中间任何位置不是数字的
select * from Students where Name like ‘%[^0-9]‘ --查询最后位置不是数字的
select * from Students where Name not like ‘%[0-9]‘

BetWeen和模糊查询,布布扣,bubuko.com

BetWeen和模糊查询

原文:http://www.cnblogs.com/sumg/p/3649446.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!