I'm fairly certain I'll need to join three SQL tables to answer these two questions, but I can't figure it out! Question 1 has me completely stumped, but I think I'm close with question 2. It's important to keep in mind that this database doesn't actually exist, only in theory.
Both Question 1 and 2 use the same tables:
Classes
ID
Name
Students
ID
Name
ClassesStudents
ClassID
StudentID
Question 1: Write a SQL query that will return the name of each class and how many students are taking it.
Question 2: Write a SQL query that will return the names of classes that the student named "John" is taking. Assume there is only one student with that name in the database.
My guess on Question 1 (WIP):
SELECT ClassesStudents.StudentID, ClassesStudents.ClassID,
Classes.Name
FROM ClassesStudents, Classes;
My guess on Question 2:
SELECT Classes.Name
FROM Students
JOIN ClassesStudents ON ClassesStudents.StudentID=Students.ID AND
Students.Name = "John"
JOIN Classes ON Classes.ID=ClassesStudents.ClassID
Can anyone please help me out? I've Googled everything I could think of :/