Assuming I have the tables student
, club
, and student_club
:
student {
id
name
}
club {
id
name
}
student_club {
student_id
club_id
}
I want to know how to find all students in both the soccer (30) and baseball (50) club.
While this query doesn't work, it's the closest thing I have so far:
SELECT student.*
FROM student
INNER JOIN student_club sc ON student.id = sc.student_id
LEFT JOIN club c ON c.id = sc.club_id
WHERE c.id = 30 AND c.id = 50