码迷,mamicode.com
首页 > 数据库 > 详细

数据库的基本操作(二)

时间:2019-01-09 13:29:43      阅读:230      评论:0      收藏:0      [点我收藏+]

标签:编号   inf   font   个数   sel   取出   语句   data-   order   

5.筛选

--top n (按个数筛选)

select * from UserInfo

select top 3 * from UserInfo

 

--top n percent * (按百分比筛选)

select top 20 percent * from UserInfo

 

--where (行筛选)

select * from UserInfo where UserId=1

 

--where (列筛选)

select UserName from UserInfo where UserId=1

 

6.排序

--排序(单重)

select * from UserInfo order by cid desc (--降序-desc,升序-asc)

--排序(多重)

select * from UserInfo order by cid asc,UserPwd desc

--(逗号前为主排序规则,逗号后为子排序规则,即如果前面的相同,则把相同的按照逗号后的规则进行排序)

 

 

7.Between ... and...语句

--取出编号从2到5的行

select * from UserInfo where UserId between 2 and 5

--取出cid编号为2或5的行

select * from UserInfo where cid in(2,5)

 

数据库的基本操作(二)

标签:编号   inf   font   个数   sel   取出   语句   data-   order   

原文地址:https://www.cnblogs.com/ss-long/p/10243605.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!