SQL集合

取交集 :intersect(取的项目必须要相同)

select  sno,sname from student intersect

select sno,sname from student where  sno>'s004' 

取差集:MINUS 去掉相同部分

select sno,sname from student  minus

select sno,sname from student where sno<'s003'

子查询

(1)单行子查询:不向外部的SQL语句返回结果或只返回一行

(2)多行子查询:向外部返回一行或多行

 

select sno,sname from student 

where asge < (select avg(sage) from student)

子查询不能包含order by

posted @ 2018-08-30 23:19  端木祈月  阅读(215)  评论(0编辑  收藏  举报