python学习之老男孩python全栈第九期_数据库day004 -- 作业
https://www.cnblogs.com/YD2018/p/9451809.html
11. 查询学过“001”并且也学过编号“002”课程的同学的学号、姓名
select student.sid,student.sname from score LEFT JOIN student on score.student_id=student.sid where (course_id=1 or course_id=2) GROUP BY score.student_id having count(course_id)>1

12. 查询学过“李平”老师所教的所有课的同学的学号、姓名
SELECT student.sid,student.sname from score LEFT JOIN student on score.student_id=student.sid where score.course_id in (SELECT course.cid from course where course.teacher_id=(select teacher.tid from teacher where teacher.tname='李平老师')) GROUP BY score.student_id having count(score.course_id) = (SELECT count(course.cid) from course where course.teacher_id=(select teacher.tid from teacher where teacher.tname='李平老师'));

13. 查询有课程成绩小于60分的同学的学号、姓名
一. group by 做:
SELECT student.sid,student.sname from score LEFT JOIN student ON score.student_id=student.sid where score.num<60 group by score.student_id;

二. distinct 做:
去重:distinct -- 效率不高
SELECT distinct student.sid,student.sname from score LEFT JOIN student ON score.student_id=student.sid where score.num<60;
14. 查询没有学全所有课的同学的学号、姓名
SELECT student.sid,student.sname from score LEFT JOIN student ON score.student_id=student.sid where score.course_id in (SELECT course.cid from course) GROUP BY score.student_id having count(score.course_id) !=(SELECT count(course.cid) from course);

python学习之老男孩python全栈第九期_数据库day004 -- 作业的更多相关文章
- python学习之老男孩python全栈第九期_数据库day004知识点总结 —— MySQL数据库day4
复习: 1. MySQL:文件管理的软件 2. 三部分: - 服务端 - SQL语句 - 客户端 3. 客户端: - MySQL - navicat 4. 授权操作: - 用户操作 - 授权操作 5. ...
- python学习之老男孩python全栈第九期_数据库day002 -- 作业 (数据库为day001创建的数据库)
1.自行创建测试数据 对score表进行优化: 添加数据: 2.查询“生物”课程比“物理”课程成绩高的所有学生的学号: 为了方便做题,额外增加几条数据 查询: 3.查询平均成绩大于60分的同学的学号和 ...
- python学习之老男孩python全栈第九期_数据库day003 -- 作业
数据库: class: course: student: teacher: score: /* Navicat Premium Data Transfer Source Server : local ...
- python学习之老男孩python全栈第九期_数据库day001 -- 作业
创建如图所示数据库: 创建过程: 查看数据库,创建数据库 db1,再查看一下数据库 进入数据库,查看一下表 接着再创建一个class表 发现增加了重复数据,因此要把第二个修改一下 修改完数据之 ...
- python学习之老男孩python全栈第九期_数据库day005知识点总结 —— MySQL数据库day5
三. MySQL视图(不常用) 给某个查询语句设置个别名(视图名),日后方便使用 - 创建: create view 视图名 as SQL; PS:视图是虚拟的 - 修改: alter view 视图 ...
- python学习之老男孩python全栈第九期_数据库day002知识点总结 —— MySQL数据库day2(全部)
一. 复习1. MySQL: - 服务端 - 客户端2. 通信交流 - 授权 - SQL语句 - 数据库 创建数据库: create database db1 default charset utf8 ...
- python学习之老男孩python全栈第九期_数据库day001知识点总结 —— MySQL操作数据库以及数据表、基本数据类型、基本增删改查、外键定义以及创建
一. 学习SQL语句规则以及外键 1. 操作文件夹 create database db2; 创建文件夹 create database db2 default charset utf8; 创建文件夹 ...
- python学习之老男孩python全栈第九期_数据库day003知识点总结 —— MySQL数据库day3
复习: 1. 增 insert into xx(name) values('root'),('xxx'); insert into xx(name) select id from tb1; 2. 自增 ...
- python学习之老男孩python全栈第九期_第一次周末考试题(over)第三次添加完毕
day 6python基础数据类型考试题 考试时间:两个半小时 满分100分(80分以上包含80分及格) 一,基础题. 1. 简述变量命名规范(3分) 答:(1) 变量为数字,字母以及下划线的任意组合 ...
随机推荐
- SpringBoot入门之事件监听
spring boot在启动过程中增加事件监听机制,为用户功能拓展提供极大的便利,sptingboot支持的事件类型有以下五种: ApplicationStartingEvent Applicatio ...
- [JavaScript] 获取昨日前天的日期
var day = new Date(); day.setDate(day.getDate()-1); console(day.pattern('yyyy-MM-dd'));//昨天的日期 day.s ...
- fail2ban
在 [DEFAULT] 全局配置中的ignoreip选项中添加被放行的ip地址:ignoreip = 127.0.0.1 172.17.1.218 网段可以加 127.0.0.1/8,用空格隔开就行. ...
- LINUX中如何查看某个端口是否被占用
之前查询端口是否被占用一直搞不明白,问了好多人,终于搞懂了,现在总结下: 1.netstat -anp |grep 端口号 如下,我以3306为例,netstat -anp |grep ...
- fullpage.js与animate.css搭配使用
jquery的fullpage.js插件的使用 https://alvarotrigo.com/fullPage/#3rdPage 官网 https://github.com/alvarotrig ...
- linux 从0开始
网络配置: http://blog.51yip.com/linux/1120.html 网络配置为自动获取 vi命令参考: http://c.biancheng.net/cpp/html/2735.h ...
- java --Method
MethodDemo class MethodDemo { public static void main(String[] args) { //调用自定义的方法. draw(4,5); draw(8 ...
- 解决Mysql Workbench的Error Code: 1175错误 无法删除数据
使用workbench,如果你要批量更新或删除数据,一般会报“ Error Code: 1175 You are using safe update mode and you tried to upd ...
- Opserver 初探三《服务器数据监控》
用Opserver 怎么像zabbix一样监控服务器呢,查看github官方说明,Opserver可用于连接任何支持Bosun, Orion, or direct WMI监控数据. Opserver ...
- Visual Studio 2015中使用gdb远程调试linux程序
VS的debug功能非常强大,相比而言linux上的图形化调试一直不是很好用. 如果可以使用VS来调试linux程序,应该是一件比较愉快的事情. 这在2015中变得可能,因为从2015开始VS支持An ...