1.查询性别为null的数据
select * from student where sex is null
2.查询性别不为null的数据
seleect * from student where is not null
3.查询性别为空字符串的数据
select * from student where sex=‘ ‘
4.查询性别不为空的数据
select * from student where sex<>‘ ‘
5.查询性别不为空且不为null的数据
select * from student where sex<>‘ ‘ and sex is not null
6.模糊查,询查学生姓孙的学生
select * from student where name like ‘孙%‘
7.模糊查询,查询名字中带杰的学生
select * from student where name like ‘杰%‘
8.模糊查询,查询名字中带两个字的学生
select * from student where name like ‘__‘
9.求总成绩
select SUM(js) from sorce
10.求平均成绩
select AVG(js) from sorce
11.求最高成绩
select MAX(js) from sorce
12.求最低成绩
select MIN(js) from sorce
13.查询本班有多少个学生
select count(*) from student
14.分页查询,起始行=(当前页-1)*每页显示的条数
第一页
select * from student limit 0,2
第二页
select * from student limit 2,2
第三页
select * from student 4,2
15.查询js成绩从大到小的顺序
select * from sorce order by js desc
16.查询js成绩从小到大的顺序
select * from sorce order by js asc
17.按照js从小到大,grade从大到小
SELECT * FROM score ORDER BY js ASC,jquery DESC;
18.按照性别分组
select sex from student group by sex
19.查询男女人数
select count(*) from student group by sex
20.查询总人数大于2的性别(分组后筛选)
select sex,count(*) from student group by sex having count(*)>1
原文地址:https://www.cnblogs.com/sunlangui/p/11429729.html