[nycphp-talk] SQL statement question
Robyn Overstreet
robyn at nyu.edu
Sun May 23 17:53:13 EDT 2004
Did you try:
SELECT * FROM history WHERE (course_fid=1 AND course_fid=2 AND
course_fid=3);
You could also use OR instead of AND, depending on the results you want.
On Sunday, May 23, 2004, at 05:42 PM, harvey wrote:
> 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!
> _______________________________________________
> talk mailing list
> talk at lists.nyphp.org
> http://lists.nyphp.org/mailman/listinfo/talk
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 2114 bytes
Desc: not available
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20040523/1867b804/attachment.bin>
More information about the talk
mailing list