求选了所有课程的学生名单
时间:2011-11-16
来源:互联网
select distinct sname from student s
where not exists(
select * from course c
where not exists(
select * from choose_course cc
where cc.cid=c.id and cc.sid=s.id))
请大家帮我解释下这个题目。这段select 就是弄不明白,
for id in(select * from student s)
loop
if(not exists(
for id in(select * from course c)
loop
if(no t exists(select * from choose_course cc where cc.cid=c.id and cc.sid=s.id))
then
output the record
end if
end loop
))
then
output the record
end if
end loop
我给它这样解释的,还是不懂
作者: xiaoxuexu 发布时间: 2011-11-16
select sname from student s
where not exists(
select * from course c
where not exists(
select * from choose_course cc
where cc.cid=c.id and cc.sid=s.id))
作者: dawugui 发布时间: 2011-11-16
一个项目涉及到的50个Sql语句(整理版)
http://topic.csdn.net/u/20100517/17/b2ab9d5e-73a2-4f54-a7ec-40a5eabd8621.html
作者: dawugui 发布时间: 2011-11-16
作者: xiaoxuexu 发布时间: 2011-11-16
-- 3. 查出没选择课程的集合为空的学生 select distinct name from student s where not exists ( -- 2.查出每个学生没有选择的课程 select * from course c where not exists ( -- 1.查出每个学生选择的课程 select * from choose_course cc where cc.cid=c.id and cc.sid=s.id ) );
作者: xiaobn_cn 发布时间: 2011-11-16
作者: xiaoxuexu 发布时间: 2011-11-16
作者: xiaoxuexu 发布时间: 2011-11-16
总体了是查询选择了课程的学生的姓名。
SQL code
select distinct name -- 2查询选择了课程的学生姓名 from student s where not exists ( select * from course c -- 1查询没有被选择的课程 where not exists ( select * from choose_course cc where cc.cid=c.id and cc.sid=s.id ) );
作者: LuiseRADL 发布时间: 2011-11-16
SQL code
for rows in(select * from student s) loop for rows in(select * from course c) loop if(not exists(select * from choose_course cc where cc.cid=c.id and cc.sid=s.id)) then --output the record 这里没有输出记录,只是返回了一个集合给外层SELECT return course record -- 1. 如果当前学生没有选择当前课程,则在课程子查询集合中加入该课程的记录 end if end loop if(not exists(course record)) then output the record -- 如果当前学生的未选择课程的集合为空,则输出该学生的记录 end if end loop
作者: xiaobn_cn 发布时间: 2011-11-16
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28