From: shrikar@aol.com (Subra Thodla)
Newsgroups: comp.databases.oracle
Subject: Re: how to write this query ( sorry typo in previous one)
Date: 10 Oct 2002 13:11:12 -0700
Organization: http://groups.google.com/
Lines: 29
Message-ID: <16be4c61.0210101211.6451b30b@posting.google.com>
References: <bce41b15.0210081657.46328aed@posting.google.com>
NNTP-Posting-Host: 162.48.138.249
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1034280672 18827 127.0.0.1 (10 Oct 2002 20:11:12 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: 10 Oct 2002 20:11:12 GMT


This should also work:

SQL> SELECT st_id, name 
   >   FROM student
   >  WHERE st_id NOT IN (SELECT st_id 
                            FROM course
                           WHERE subj_id IN ('23','24'))

Hope this helps ...

kumar_kmk@hotmail.com (Kumar) wrote in message news:<bce41b15.0210081657.46328aed@posting.google.com>...
> I have these tables
> 
> student( st_id,name)
> subject (subj_id,name)
> course (st_id,subj_id)    1 student can takemutiple subjects.
> 
> I want a query to find all students who did not take any of subj_id's say 23,24
> 
> So if 
> student1 takes subjects 21,22,45
> student2 takes 1,12,23,67,75
> student3 takes 14,23,24,27
> student4 takes 1,2,3,4
> 
> The query should return me studentid's 1 and 4 only
> 
> Thanks
> Kumar

