当前位置:Gxlcms > 数据库问题 > Mysql—表内容的增删改查02

Mysql—表内容的增删改查02

时间:2021-07-01 10:21:17 帮助过:43人阅读

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

 

Mysql—表内容的增删改查02

标签:成绩   女人   having   and   sum   内容   数据   jquery   学生   

人气教程排行