[nycphp-talk] SQL statement question
harvey
list at harveyk.com
Sun May 23 17:42:10 EDT 2004
Hello,
I'm going to create a MySql table that looks something like the following (I think). It's a history of courses taken by students.
History_ID Student_FID Course_FID
1 34 2
2 17 7
3 21 5
4 02 5
5 34 5
6 17 4
... ... ...
I'd like to be able to say which students have met the requirements of certain programs. So, I need a statement that will produce a list of Student_FID's that are matched with a particular set of Course_FID's. For instance, which students took both course 5 and course 2?
So, I'm trying subqueries to find students who have taken courses 1,2,and 3:
"SELECT *
FROM
(SELECT *
FROM
(SELECT *
FROM history
WHERE course_fid = 3)
AS id3
WHERE course_fid = 2)
AS id2
WHERE course_fid = 1"
I get an error that my sql syntax is wrong. Maybe it is. Or maybe my host's version of MySQL is too old? Is there a better SQL statement? Any help is appreciated...
Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20040523/0fcc2d8b/attachment.html>
More information about the talk
mailing list