Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Sql Query Help please
Try this:
SELECT student_id
FROM classes_attended
WHERE class_name='class1'
INTERSECT
SELECT student_id
FROM classes_attended
WHERE class_name='class2'
INTERSECT
SELECT student_id
FROM classes_attended
WHERE class_name='class3',
etc.
Hope this helps.
Michael Serbanescu
>I have 2 tables, students and classes_attended in a 1 to many
>relationship.
>
>I need a query that will select students that have attended a specific
>set of classes and only if they have attended ALL the classes
>specified ( that's why a OR where clause dosen't work) - any ideas?
>
>stud_nbr is the key field in both tables.
>
>Thanks,
>John Greco
>Oracle DBA suffering from 'out-of-memory' error in brain.
>
Received on Fri Oct 31 1997 - 00:00:00 CST