sql语句札记
组合查询:
sql的组合查询操作符有UNION(并操作),INTERSECT(交操作)和MINUS(差操作)3种
1.union操作与条件or等价
2.interset不与and等价
3.minus例子:求选修了c1课程但没有选修c2课程的学生的学号 select xuhao from xuanke where kch='c1' minus select xuhao from xuanke where kch='c2'
等价于
select xuehao from xuanke x1 where kch='c1' and not exists (select xh from xuanke xk2 where xk1.xh=xk2.xh and xk2.kch='c2');