1、数据库是按照原文制作的,表格结构一样具体存储的数据有些差异

原文地址:MySQL练习题

原答案地址:MySQL练习题参考答案

2、查询“生物”课程比“物理”课程成绩高的所有学生的学号;

select wl.sid from (select sc.student_id as sid,sc.number as grade from score sc,course c
where c.cid=sc.course_id and c.cname='物理') as wl,(select sc.student_id as sid,sc.number as
grade from score sc,course c where c.cid=sc.course_id and c.cname='生物') as sw where
wl.sid=sw.sid and sw.grade>wl.grade;

3、查询平均成绩大于60分的同学的学号和平均成绩;

select student_id,avg(number) as avg from score group by student_id having avg(number)>60;

4、查询所有同学的学号、姓名、选课数、总成绩;

select s.sid,s.sname,w.total,w.sum from student s,(select student_id,count(course_id) as
total,sum(number) as sum from score group by student_id) as w where s.sid=w.student_id;

5、查询姓“李”的老师的个数;

select count(*) from teacher where tname like '钱%';

6、查询没学过“叶平”老师课的同学的学号、姓名;

select s.sid,s.sname from student as s where s.sid not in (select distinct sc.student_id from
score as sc,teacher as t,course as c where t.tid=c.teacher_id and c.cid=sc.course_id and
t.tname='赵');

7、查询学过“001”并且也学过编号“002”课程的同学的学号、姓名;

select student.sid,student.sname from student,(select * from score where course_id=1) as w,
(select * from score where course_id=2) as e where w.student_id=e.student_id and
student.sid=w.student_id;

8、查询学过“叶平”老师所教的所有课的同学的学号、姓名;

select s.sid,s.sname from student as s where s.sid in (select distinct sc.student_id from
score as sc,teacher as t,course as c where t.tid=c.teacher_id and c.cid=sc.course_id and
t.tname='赵');

9、查询课程编号“002”的成绩比课程编号“001”课程低的所有同学的学号、姓名;

select student.sid as id,student.sname as name from student,(select w.student_id as wid from
(select * from score where course_id=1) as w,(select * from score where course_id=2) as e
where w.student_id=e.student_id and w.number>e.number) as m where m.wid=student.sid;

10、查询有课程成绩小于60分的同学的学号、姓名;

select s.sid as id,s.sname as name from student as s,score as sc where s.sid=sc.student_id
and sc.number<60 group by s.sid;

11、查询没有学全所有课的同学的学号、姓名;

select sid,sname from student where sid in (select distinct student_id from score group by
student_id having count(course_id)=(select count(*) from course));

12、查询至少有一门课与学号为“001”的同学所学相同的同学的学号和姓名;

select sid,sname from (select distinct student_id from score left join (select course_id from
score left join student on score.student_id = student.sid where student.sid=1) as c on
score.course_id = c.course_id where student_id != 1) s left join student on
s.student_id=student.sid;

13、查询至少学过学号为“001”同学所有一门课的其他同学学号和姓名;

select student.sid,student.sname from student right join score on
student.sid=score.student_id where student_id!=1 and course_id in (select course_id from
score where student_id=1) group by student_id having count(course_id)=(select count
(course_id) from score where student_id=1);

14、查询和“002”号的同学学习的课程完全相同的其他同学学号和姓名;

select sid,sname from student where sid in (select student_id from score right join (select
course_id from score where student_id=1) w on score.course_id=w.course_id where student_id!=1
group by student_id having count(student_id)=(select count(*) from score where
student_id=1));

15、删除学习“叶平”老师课的SC表记录;

delete from score where course_id in (select cid from teacher,course where
teacher.tid=course.teacher_id and teacher.tname='周');

16、向SC表中插入一些记录,这些记录要求符合以下条件:①没有上过编号“002”课程的同学学号;②插入“002”号课程的平均成绩;

insert into score(student_id,course_id,number) select sid,1,(select avg(number) from score
where course_id=1) from student where sid not in (select student_id from score where
course_id=1);

未完待续

转载于:https://www.cnblogs.com/kumu/p/6623331.html

mysql练习题练习相关推荐

  1. python条件表达式三门课至少有一门及格_Python/ MySQL练习题(一)

    Python/ MySQL练习题(一) 2.查询"生物"课程比"物理"课程成绩高的所有学生的学号 1 SELECT2 * 3 FROM4 (5 SELECT6 ...

  2. MySQL等级考试题目练习_全国计算机等级考试二级MySQL练习题

    全国计算机等级考试二级MySQL练习题 为了使广大考生在备战计算机等级考试时,更快的掌握相应知识点,下面是小编搜索整理的全国计算机等级考试二级MySQL练习题,供参考练习,预祝考生们考出自己理想的成绩 ...

  3. 计算机二级mysql大题_2016年计算机二级MySQL练习题及答案

    1[填空题]数据库系统的三级模式结构是指数据库系统是由________.________和________三级构成. 参考解析:模式 外模式 内模式 2[简答题]请简述PHP是什么类型的语言? 参考解 ...

  4. mysql练习题及答案_mysql练习题及答案.doc

    mysql练习题及答案 mysql练习题及答案 mysql查询语句练习题 Sutdent表的定义 字段名 字段描述 数据类型 主键 外键 非空 唯一 自增 Id 学号 INT 10 是 否 是 是 是 ...

  5. 二级mysql大题_全国计算机等级考试二级MySQL练习题及答案

    下半年的计算机等级考试将在九月份举行,下面小编为大家带来了全国计算机等级考试二级MySQL练习题及答案,欢迎大家阅读! 全国计算机等级考试二级MySQL练习题及答案 一.选择题 1.在MySQL中,通 ...

  6. 数据库系统原理与应用教程(077)—— MySQL 练习题:操作题 168-172(二十一):综合练习

    数据库系统原理与应用教程(077)-- MySQL 练习题:操作题 168-172(二十一):综合练习 168.分组统计(1) 该题目使用的表和数据如下: /* DROP TABLE IF EXIST ...

  7. 数据库系统原理与应用教程(070)—— MySQL 练习题:操作题 101-109(十四):查询条件练习

    数据库系统原理与应用教程(070)-- MySQL 练习题:操作题 101-109(十四):查询条件练习 101.判断空值(1) 试卷答题记录表:exam_record(uid:用户ID,exam_i ...

  8. 查询计算机系和英语系的学生信息,MySQL练习题1

    以下SQL操作均在MYSQL上测试过 首先是表定义 1.创建student和score表 CREATE TABLE student ( id INT(10) NOT NULL UNIQUE PRIMA ...

  9. 计算机二级mysql基本操作题怎么做_计算机等级考试二级教程MySQL练习题

    计算机等级考试二级教程MySQL练习题 多做练习题是为了巩固已学到的知识,下面小编为大家带来了计算机等级考试二级教程MySQL练习题,欢迎大家阅读! 计算机等级考试二级教程MySQL练习题 一.选择题 ...

最新文章

  1. Yoshua Bengio团队通过在网络「隐藏空间」中使用降噪器以提高深度神经网络的「鲁棒性」...
  2. 利用正则表达式去除所有html标签,只保留文字
  3. C Screen Shot Implementation
  4. java Graphics2D类
  5. redis和memcached的区别(总结)
  6. 恢复SQLSERVER被误删除的数据
  7. HDU 1698 Just a Hook 线段树
  8. mysql 存储过程发邮件_通过sql存储过程发送邮件的方法
  9. Nginx/Apache/Tomcat记录屏蔽真实IP
  10. 三言两语说清“线性流程”
  11. 如何在Windows上安装多个MySQL
  12. 如何判断单链表里面是否有环【转载】
  13. Android开发之Activity(实现Activity跳转)
  14. 2018注册测绘师各地报名时间和注意事项!莫错过哦!
  15. 人机对话系统的对话管理
  16. 手动下载Windows Defender离线更新包
  17. impala hive随机抽样方法
  18. Win7 远程桌面限制IP
  19. 悉尼大学计算机学士,2017年悉尼大学计算机学士介绍
  20. dad my_My dad英语绘本.ppt

热门文章

  1. linux ping 虚拟网卡_虚拟机中Linux系统网卡的配置
  2. java中paint_java中paint()的具体用法是什么?
  3. 1.10 理解人的表现
  4. opencv-api getStructuringElement
  5. pandas 散布矩阵
  6. Pandas DataFrame 去重
  7. Eclipse字符集环境配置
  8. 存储技术论坛:最高可用级别的同步复制及方案
  9. Csico CCNA学习笔记1_cdp telnet
  10. mysql备份到制定目录_写一个脚本定时自动备份mysql到指定目录