Nested Subqueries:
A subquery is aselect-from-where
expression that isnested within another
query.(子查询是嵌套在另一个查询中的select-from-where表达
式)
测试一个元组是否是某个集合中的元素,用 in , not in
1.
“Find allthe courses taught in the both the
Fall2009 and Spring 2010 semesters.”
Step 1 :
(select courseid
from section
where semester = ‟Spring‟ and year= 2010)
step 2:
2.
“Find allthe courses taught in the both the
Fall 2009but not in Spring 2010 semesters.”
select distinctcourse_id
from section
where semester = ‟Fall‟ and year= 2009
and course_id not in (select course_id
from section
where semester = ‟Spring‟ and year= 2010);
3.n