码迷,mamicode.com
首页 > 其他好文 > 详细

第四章 数据查询(上)

时间:2020-01-01 18:40:56      阅读:84      评论:0      收藏:0      [点我收藏+]

标签:des   别名   select   top   bsp   第四章   neu   auto   数据查询   

查询语句:

select <列名> 

from <表名>

[where <查询条件表达式>]

[ order by <排序的列名>[asc或desc] ]

  asc升序(缺省)  

  desc降序

使用as来命名列(取别名)

select Scode as 学员编号, Sname as 学员姓名, Saddress as 学员地址

from students

where Saddress<>‘河南新乡’

 

select FirstName + ‘.‘ + LastName AS ‘姓名‘ from Employees

 

 

查询空行

select SName from students where Semail IS NULL

 

查询非空行

select sname from students where not semail is null

或

select sname from students where semail is  not   null

 

限制固定行数

select top 5 sname, saddress 

from students where ssex = 0

 

返回百分之多少行

select top 20 percent sname, saddress 

from students where ssex = 0

 

 

 

 

第四章 数据查询(上)

标签:des   别名   select   top   bsp   第四章   neu   auto   数据查询   

原文地址:https://www.cnblogs.com/ftyl/p/12129374.html

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