Exercise: Three Tables
Join students, courses, and departments.
Solution
sql
1SELECT s.name, c.course_name, d.dept_name
2FROM students s
3JOIN courses c ON s.course_id = c.id
4JOIN departments d ON c.dept_id = d.id;
Join students, courses, and departments.
1SELECT s.name, c.course_name, d.dept_name
2FROM students s
3JOIN courses c ON s.course_id = c.id
4JOIN departments d ON c.dept_id = d.id;