1、查询student表中所有记录
select *from student;
2、查询student表中部分列var1,var2
select var1,var2 from student;
3、查询student表中某列但排除重复值
使用distinct即可
select distinct var2 from student;
4、查询student表中某列(比如成绩)在某一区间
使用条件where,between …and即可
select *from student where score between 60 and 70;
5、查询student表中某列(比如成绩)在某一区间
使用条件where,between …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="女";