我有一个语法错误,我不知道如何解决。我是MySQL的新手,错误消息让我感到困惑。
Select dept_name, total_student, total_instuctor, total_course
From department as d
natural left join ( select dept_name count( dept_name ) as total_student
from student
group by dept_name) as s
natural left join ( select dept_name count( dept_name ) as total_instructor
from instructor
group by dept_name) as i
natural left join ( select dept_name count( dept_name ) as total_course
from course
group by dept_name) as c
Group By dept_name
Order By count( total_student ) desc;
当前收到错误消息“此服务器版本在此位置的select无效,期望:'(',WITH”加下划线的Select是第一个。
最佳答案
您忘记了子查询选择中的所有,
:
Select dept_name, total_student, total_instuctor, total_course
From department as d
natural left join ( select dept_name, count( dept_name ) as total_student
from student
group by dept_name) as s
natural left join ( select dept_name, count( dept_name ) as total_instructor
from instructor
group by dept_name) as i
natural left join ( select dept_name, count( dept_name ) as total_course
from course
group by dept_name) as c
Group By dept_name
Order By count( total_student ) desc;
关于mysql - 添加子查询时,“选择在此位置对于服务器版本无效……”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55316582/