Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Ask Question
I have a syntax error, and I don't know how to fix it. I'm kind of new to MySQL and the error message is just confusing me.
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;
currently getting an error message "select is not valid at this position for this server version, expecting : '(', WITH" the Select that is underlined is the very first one.
You forgot all the ,
in the subquery selects:
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;
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.