Re: SQL Select

From: Michael Serbanescu <mserban_at_postoffice.worldnet.att.net>
Date: 1997/10/01
Message-ID: <3431D9BB.6EBA_at_postoffice.worldnet.att.net>#1/1


You could try this:

SELECT StudentID FROM taken
WHERE ClassTitle='CS101'
INTERSECT
SELECT StudentID FROM taken
WHERE ClassTitle='CS200'
INTERSECT
SELECT StudentID FROM taken
WHERE ClassTitle='CS300';

Or you could use a triple self-join of the TAKEN table.

Hope this helps.

Michael Serbanescu



Mark McCubbin wrote:
>
> I need help with an SQL query to determine which students have taken two
> or more courses. For example, what is the most efficient way to answer
> the question: who has taken all three classes CS101, CS200, and CS300?
>
> The tables are as follows (the relationship is one to many):
>
> STUDENT
> StudentID
> FirstName
> LastName
>
> TAKEN
> ClassTitle
> StudentID
Received on Wed Oct 01 1997 - 00:00:00 CEST

Original text of this message