子查询的定义?sql
一个查询语句包含了查询语句就叫子查询spa
select语句中能够嵌套select语句,被嵌套的select语句就是子查询 code
子查询出现的位置?it
子查询能够包含普通select能够包括的任何子句,好比:distinct、 group by、order by、limit、join和union等;可是对应的外部查询必须是如下语句之一:select、insert、update、delete、set或 者doio
通常子查询出如今select、from、where中class
使用date
在select中select
SELECT student_no, (SELECT sum(student_result)FROM result WHERE student_result > 80 ) AS 'sumResult' FROM result WHERE student_result > 80
在where中nio
SELECT student_no FROM result WHERE student_result > (SELECT avg(student_result) FROM result)