【发布时间】:2017-10-01 09:59:43
【问题描述】:
我在 MySQL 中遇到以下问题
问题出现在别名“T”
select course_id, sec_id, enrollment
from (
select course_id, sec_id, count(ID) as enrollment
from section natural join takes
where semester = 'Fall' and year =2009
group by course_id, sec_id
) as T
where enrollment = (select max(enrollment) from T);
【问题讨论】:
-
自然连接令人讨厌 - 使用显式连接更容易理解(对于阅读器和优化器)。
-
你应该阅读mysql的执行顺序。在执行顺序中选择出现在 where 之后这一事实与此相关。
标签: mysql