Mysql数据库查询语句

烂漫一生 提交于 2020-01-18 04:39:46

1、查询student表中所有记录

select *from student;

2、查询student表中部分列var1,var2

select var1,var2 from student;

3、查询student表中某列但排除重复值

使用distinct即可

select distinct var2 from student;

4、查询student表中某列(比如成绩)在某一区间

使用条件wherebetween …and即可

select *from student where score between 60 and 70;

5、查询student表中某列(比如成绩)在某一区间

使用条件wherebetween …and即可

select *from student where score between 60 and 70;

6、表示某列区间或关系的查询in

查询成绩为66,77,88的学生

select *from student where score in(66,77,88)

7、表示两列或多列的条件查询or

查询成绩大于66,或者性别为女的学生

select *from student where score >66 or sex="女";

8、对某列进行降序升序

默认升序asc,降序desc

select *from student where order by score desc;

9、根据两列进行降序升序

select *from student where order by score desc,score2 asc ;

9、根据两列进行降序升序

默认升序asc,降序desc

select count(*)from student where sex="女";
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!