——————————子查询—————————————-
———–将查询的结果作为子表,连表查询
select * from StuInfo s1,(select * from StuMarks where Score >80)s2 where s1.StuID=s2.StuID AND s1.StuName=’李四’
———–将查询结果作为条件使用
select * from StuInfo WHERE StuID>(select StuID from StuInfo where StuName=’王五’)
———–将子查询作为临时表使用
select s1.,s2 Score from StuInfo s1 left outer join (select from StuMarks where Subject=’HTML’) s2 on s1.StuID=s2.StuID
———–将子查询作为列使用 (不建议使用)
select s1.*,(select Score from StuMarks s2 where s1.StuID=s1.StuID and subject=’html’) Score from StuInfo s1
———–使用in 和not in 完成子查询
select StuName from StuInfo where StuID In (select StuID from StuMarks where Score >85 and Subject=’java’)
———–使用exist 或not exist 完成子查询
select * from StuInfo where exists (select * from StuMarks where StuMarks.StuID=StuInfo.StuID)
———–使用some 、any、 all进行子查询
——————–聚合函数—————————————————–
—————使用compute 和compute by进行汇总
———————-排序函数
—————排序函数