首页 > 数据库技术 > 详细

数据库查询

时间:2014-11-25 10:31:54      阅读:248      评论:0      收藏:0      [点我收藏+]

use mydb

select *from Category where Parent=‘013‘ or parent=‘011‘ or Parent=‘012‘

--in 代表在某些参数范围之内的都符合条件,相当于多个or

select *from Category where Parent in(‘013‘,‘011‘,‘012‘)

--not 起修饰作用,取反

select *from Category where Parent not in (‘013‘,‘011‘,‘012‘)

--between and 表示在某范围之内,相当于>= <=

select *from Category where Ids>500 and Ids<505

select *from Category where Ids between 500 and 505

--模糊查询,行业里带国家两个字的 like

select *from Category where Name like‘%国家%‘

select *from Category where Name like‘国家%‘

select *from Category where Name like‘%机构%‘

--查询某一列里带国家两个字用‘%国家%‘

--查询某一列里带国家两个字开头的‘国家%"

--查询某一列里以国家结尾‘%国家‘

--不带某个字的not like

select *from Category where Name not like ‘%国家%‘

--查询某一列,用列名代替*

 

select code ,name from Category where Ids >5 and Ids <10

select code from Category where Ids >5 and Ids <10

select Ids from Category where Ids in (6,7,8,9)

select *from Category where Ids>all

(

select Ids from Category where Ids in (6,7,8,9)

)

select *from Category where Ids>all

(

select Ids from Category where Ids>1190 and Ids <1195

)

--查询一列当作参数使用

-->any大于查询出来的任何一个(最小数)

-->all大于查询出来的所有的(最大数)

 

数据库查询

原文:http://www.cnblogs.com/yangyue/p/4120178.html

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