I have the following tables:
STUDENT
studentID fullName
1 John Smith
2 John Doe
3 Bob Marley
4 George Bush
CLASS
classID className
1 Maths
2 IT
3 Spanish
4 Science
5 Colouring in
STUDENT_CLASS
studentID classID
1 1
1 3
2 1
3 1
3 2
3 4
4 5
What I want to do is select a CLASS and see which students are studying
that class. So, if I wanted to search Maths, I want to see the results:
John Smith
John Doe
Bob Marley
Obviously, I can do this by writing a script to capture the studentIDs
and then fetch each name. But is it possible to do this in a single SQL
statement?
Brown Cat:
> I have the following tables:
> STUDENT
> CLASS
> STUDENT_CLASS
> What I want to do is select a CLASS and see which students are studying
> that class. [...] But is it possible to do this in a single SQL
> statement?
This appears a home work excercise to me.
Probably, you should read up on one of the most important (and basic) SQL
features: JOIN
--
Erick