Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Sql Query Help please

Re: Sql Query Help please

From: Tim McConechy <tmcconec_at_wie.com>
Date: 1997/10/30
Message-ID: <345917BB.7963B6BD@wie.com>#1/1

Try something using temp tables,

create table temp as select class_name,stud_nbr

    from class_attended where class_name in ('class1','class2'....) group bystud_nbr;

select s.whatevercloumns
from students s, classes_attended c
where c.stud_nbr=s.stud_nbr --join on the key and s.class_name||to_char(s.stud_nbr) in (select class_name||to_char(stud_nbr) from temp);

--Assuming class name is a varchar and stud_nbr is a number

Not positive this will work but maybe you will get a few ideas!

Good Luck

TurkBear wrote:

> 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 Thu Oct 30 1997 - 00:00:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US