SQL语句的执行流程

来源:百度知道 编辑:UC知道 时间:2024/07/04 22:03:31
请问下这个sql语句的执行流程,越详细越好
select distinct a.press
from book a
where (select avg(price) from book b where a.press = b.press) < 35
order by a.press

1. 从a表取第一条记录
2. 从b表取press与该记录的press值相等的记录
3. 对b表取出的记录price进行平均
4. 如果该平均值<35,则a表第一条存入临时结果集

5. 循环对a表的每一条记录执行1-4步骤,直到结尾

6. 对临时结果集排序并去重复,然后输出最终结果

第一行:查询出 distinct(不相同的) 作者字段 press
第二行:from book a 查询的表明 起个别名 a
第三行: where 条件 平均条件<35
第四行: order by a.press 排序作者字段默认升序