| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 808 人关注过本帖
标题:嵌套子查询研究
只看楼主 加入收藏
makebest
Rank: 8Rank: 8
等 级:蝙蝠侠
威 望:3
帖 子:658
专家分:962
注 册:2005-3-17
收藏
 问题点数:0 回复次数:1 
嵌套子查询研究

研究如下几个子查询及其区别,将有助于大家子查询的理解:

查询选修了任何一门课程的学生 (最容易理解)
select * from 学生
where exists
( select * from 课程
where exists
( select * from 成绩
where 课程号=课程.课程号 and 学号=学生.学号
)
)

查询没有选修全部课程的学生
select * from 学生
where exists
( select * from 课程
where not exists
( select * from 成绩
where 课程号=课程.课程号 and 学号=学生.学号
)
)

查询没有选修一门课程的学生
select * from 学生
where not exists
( select * from 课程
where exists
( select * from 成绩
where 课程号=课程.课程号 and 学号=学生.学号
)
)

查询选修每门课程的学生
select * from 学生
where not exists
( select * from 课程
where not exists
( select * from 成绩
where 课程号=课程.课程号 and 学号=学生.学号
)
)

搜索更多相关主题的帖子: 嵌套 课程 STRONG select 
2005-12-01 21:25
nic
Rank: 2
等 级:新手上路
威 望:4
帖 子:175
专家分:0
注 册:2005-11-1
收藏
得分:0 
谁能解析一下这样的查询原理?

2005-12-02 12:03
快速回复:嵌套子查询研究
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017025 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved