第四章 select where过滤

来源:互联网 发布:炭知天下电话 编辑:程序博客网 时间:2024/06/05 04:01

假如有一张 学生表

select * from student 

列名 可以用别名 表名也可以用别名

select t.name as '名字' from student t

列可以做加减乘除 列也可以自定义常量列 

select t.score-1 ,5 as '五'from student t

(t.列名 必须这个表中存在这个列才会显示否则报错)

单词:排序 order by 降序 desc 升序 asc   limit 限量

查询前五名的同学的成绩

select t.score from student t  order by desc limit 5 (如果有where 要加在order by 前面)

查询成绩为60,90,95的人

select score from student in (60,90,95)   (反之则not in)

查询成绩为空的人null

select t.score from student where score is null (反之则 is not)

between 指定两个数之间的值(包含这两个数)

注意:如果where后面有and和or 必须要先算and再算or

0 0
原创粉丝点击