c#='1001' 能放在里面吗?
我理解exists怎么很费劲呢?select s# from sc a where c#='1001' and exists
(select* from sc where a.s#=s# and c#='002' and score<a.score)背景
Student(S#,Sname,Sage,Ssex) 学生表
Course(C#,Cname,T#) 课程表
SC(S#,C#,score) 成绩表
Teacher(T#,Tname) 教师表
5、查询没学过“叶平”老师课的同学的学号、姓名;
题外话:
http://topic.csdn.net/u/20091007/06/6b7794bd-2558-4a33-a9fc-d50cd4cc70c6.html?50153
从2楼到27楼
:2009-10-07 07:21:30---2009-10-07 07:27:12 真够紧张的
我理解exists怎么很费劲呢?select s# from sc a where c#='1001' and exists
(select* from sc where a.s#=s# and c#='002' and score<a.score)背景
Student(S#,Sname,Sage,Ssex) 学生表
Course(C#,Cname,T#) 课程表
SC(S#,C#,score) 成绩表
Teacher(T#,Tname) 教师表
5、查询没学过“叶平”老师课的同学的学号、姓名;
题外话:
http://topic.csdn.net/u/20091007/06/6b7794bd-2558-4a33-a9fc-d50cd4cc70c6.html?50153
从2楼到27楼
:2009-10-07 07:21:30---2009-10-07 07:27:12 真够紧张的
如
exists (select 1 from sc from s.c# = 001...
放到里面应该条件不起作用..
外面的条件和exists是并列同级的
join sc on sc.s# = s.s#
join course c on sc.c# = c.c#
join teacher t on c.t# = t.t#
where t.tname = '叶平' and sc.score < 60
指定一个子查询,检测行的存在。 语法
EXISTS subquery参数
subquery是一个受限的 SELECT 语句 (不允许有 COMPUTE 子句和 INTO 关键字)。有关更多信息,请参见 SELECT 中有关子查询的讨论。 结果类型
Boolean结果值
如果子查询包含行,则返回 TRUE。
select s# from sc a where exists
(select* from sc where a.s#=s# and a.c# = '1001' and c#='002' and score<a.score)但是不好读