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

猜你喜欢

转载自www.cnblogs.com/Syue/p/9563316.html