ITeye博客

sql语句札记

cetusz · 2010-10-11 15:09 · sql · 数据库 · Markdown

组合查询:

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');

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。