第四章 数据查询(上)

<style></style>

查询语句:

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

 

 

 

 

上一篇:SQL基础语法—create语句


下一篇:2019.11.30 Mysql查询知识