找回密码
 立即注册
gz_wangpeisi +好友
这个人很懒什么都没写
听众
1
主题
0
金钱
18
个人名片
  • 未填写地址
  • 这家伙很懒什么都没写
粉丝关注
还没有人关注TA
添加表情

数据库单表练习

已有 156 次阅读2021-5-9 19:35

1、查询1832班的成绩信息
mysql> select * from class where class=1832;

2,查询1833班,语文成绩大于80小于90的成绩信息 
mysql> select * from class where class=1833 and  chinese>80 and chinese<90;

3,查询学生表中5到10行的数据 
mysql> select * from class where id limit 4,10;

4,显示1832班英语成绩为98,数学成绩为77的姓名与学号,
mysql> select id,name from class where class=1832  and math=77 and english=98;

 5,查询出1832班成绩并且按语文成绩排序(降序)
mysql> select * from class where class=1832 order by chinese desc;

 6,查询1833班与1832班,语文成绩与数学成绩都小于80的姓名。
mysql> select name from class where class in(1832,1833) and chinese<80 and math<80;
 
7,查询出没有参加语文考试的学生姓名和班级名称。
mysql> select name,class from class where chinese is null;

 8,求出班上语文成绩不及格的学生姓名
mysql> select name from class where  chinese<60 group by class;

 9,求出每个班的数学平均成绩 
mysql> select class,avg(math) from class group by class;

10、求出每个班级语文成绩总分 --涉及到每个的时候都需要分组
mysql> select class,sum(chinese) from class group by class;
 
11、将语文成绩不及格的学生成绩改为60分
mysql> update class set chinese=60 where chinese<60;

12、三科分数都大于70分的人名和年纪
mysql> select name,age from class where chinese>70 and math>70 and english>70; 

13、求出英语分数高于70且其它任何一科目大于60分的人和班级
mysql> select name,class from class where english>70 and math>60 or chinese>60;

14、统计每个班的人数 
mysql> select class,count(id) from class group by class;

15、求每个班数学成绩大于80的人数 
mysql> select class,count(*) from class where math>80 group by class;

17、给student表增加3个字段(数据类型及长度自定义,建议要合理),
 mysql> alter table class add(sex int(20),chemistry int(20),history int(20));

全部作者的其他最新日志

评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 立即注册