集合查询:(确保属性一样)
union:并操作
例1:查询选修了1号课程或2号课程的学生的学号。
select sno from sc where cno='1'
union
select sno from sc where cno='2';
intersect:交操作
例2:查询既选修了1号课程又选修了2号课程的学生的学号。
select sno from sc where cno='1'
intersect
select sno from sc where cno='2';
except:差操作
例3:查询选修了2号课程但没有选修3号课程的学生的学号和课程号
select sno,cno from sc where cno='2'
except
select sno,cno from sc where cno='3';