MySQL 查询练习记录
2024-09-01 12:39:26
MySQL 查询练习记录
最近在复习mysql,在b站上找了一个感觉还不错的视频,把视频中查询练习相关的内容记录了下来,以便自己日后查阅和复习。
视频连接:https://www.bilibili.com/video/av39807944/?p=1
数据准备
创建数据表
学生表 student:
1 |
create table student( |
教师表 teacher:
1 |
create table teacher( |
课程表 course:
1 |
create table course( |
成绩表 score:
1 |
create table score( |
添加数据
1 |
-- 学生表 |
查询练习题汇总
- 查询student表的所有记录
- 查询student表中的所有记录的name、sex和class列
- 查询教师所有的部门即不重复的depart列
- 查询score表中成绩在60到80之间的所有记录
- 查询score表中成绩为85,86或88的记录
- 查询student表中“95031”班或性别为“女”的同学记录
- 以class降序查询student表的所有记录
- 以cno升序、degree降序查询score表的所有记录
- 查询“95031”班的学生人数
- 查询score表中的最高分的学生学号和课程号(子查询或者排序)
- 查询每门课的平均成绩
- 查询score表中至少有2名学生选修的并以3开头的课程的平均分数
- 查询分数大于70,小于90的sno列
- 查询所有学生的 sname、cno 和 degree 列
- 查询所有学生的sno、cname和degree列
- 查询所有学生的sname、cname和degree列
- 查询“95031”班学生每门课的平均分
- 查询选修“3-105”课程的成绩高于“109”号同学“3-105”课程成绩的所有同学的记录
- 查询成绩高于学号为“109”、课程号为“3-105”的成绩的所有记录
- 查询和学号为108、101的同学同年出生的所有学生的sno、sname和sbirthday列
- 查询“张旭”教师任课的学生成绩
- 查询选修某课程的同学人数多于5人的教师姓名
- 查询“95033”班和“95031”班全体学生的记录
- 查询存在有85分以上成绩的课程cno
- 查询出“计算机系”教师所教课程的成绩表
- 查询“计算机系”和“电子工程系”不同职称的教师的tname和prof
- 查询选修编号为“3-105”课程且成绩至少高于选修编号为“3-245”的同学的cno、sno、和degree,并按degree从高到低次序排序
- 查询选修编号为“3-105”课程且成绩高于选修编号为“3-245”的同学的cno、sno、和degree
- 查询所有教师和同学的name、sex和birthday
- 查询所有“女”教师和“女”同学的name、sex和birthday
- 查询成绩比该课程平均成绩低的同学的成绩表
- 查询所有任课教师的name和depart
- 查询至少有两名男生的班号
- 查询student表中不姓“王”的同学记录
- 查询student表中每个学生的姓名和年龄
- 查询student表中最大和最小的sbirthday日期值
- 以班号和年龄从大到小的顺序查询student表中的全部记录
- 查询男教师及其所上的课程
- 查询最高分同学的sno、cno和degree列
- 查询所有和李军同性别的同学的名字
- 查询和“李军”同性别并同班的同学的名字
- 查询所有选修“计算机导论”课程的“男”同学的成绩表
- 假设使用如下命令创建了一个grade表:
1
2
3
4
5
6
7
8
9
10
11 > create table grade(
> low int(3),
> up int(3),
> grade char(1)
> );
> insert into grade values(90,100,"A");
> insert into grade values(80,89,"B");
> insert into grade values(70,79,"C");
> insert into grade values(60,69,"D");
> insert into grade values(50,59,"E");
>
现查询所有同学的sno、cno和grade列。
参考答案
1 |
1. select * from student; |
EOF
最新文章
- How do servlets work-Instantiation, sessions, shared variables and multithreading[reproduced]
- .Net中的泛型(where T : class的含义)
- 你可能不知道的Google Chrome命令行参数
- IOS基础框架
- zip文件解压或压缩
- [BZOJ 2738] 矩阵乘法 【分块】
- 在MFC主对话框OnInitDialog()中弹出对话框
- pureMVC java版搭建流程
- struts2 maven整合tiles3
- c++趣味之变量名,颠覆所有教科书的VisualStudio
- Docker学习笔记之二:制作镜像并PUSH
- jenkins Pipeline 使用
- 关于byte[]与string、Image转换
- redis 的消息队列 VS kafka
- Django框架之验证码生成示例
- Mac软件推荐
- 0302-对IT行业的感思
- CI框架伪静态化配置
- 关于B/S和C/S模式
- ios 屏幕旋转的问题
热门文章
- 自动增量更新war包的shell脚本
- BZOJ 1634 [Usaco2007 Jan]Protecting the Flowers 护花:贪心【局部分析法】
- Unity-2017.3官方实例教程Space-Shooter(二)
- ubuntu svn 常用命令
- bzoj 3230 相似子串 —— 后缀数组+二分
- 微软开业网站----精华 http://www.microsoft.com/opensource/directory.aspx
- WPF win7+vs2010开发的打印功能,怎么在XP系统上无法打印
- Oracle数据去重
- wpf窗口禁止最大化但允许调整大小
- 当在hive中show&;nbsp;table&;nbsp;…