Re: Another way

From: Thomas Muller <ttm_at_nextra.com>
Date: 2000/03/22
Message-ID: <Qr%B4.20677$6b1.370250_at_news1.online.no>#1/1


Joe "Nuke Me Xemu" Foster <joe_at_bftsi0.UUCP> wrote in message news:sdfnui4qlul14_at_corp.supernews.com...
> "MICHAIL K. GKIOURTAS" <michgkio_at_otenet.gr> wrote in message
 news:01bf92b3$461a6740$a06aa7c3_at_default...
>
> > We have the following relations(attached)
 

> > a)How will I find the names of all juniors who are enrolled in a class
> > taught by J. Hill, using SQL-92 joins?
> > b)Using joins again, how will I find the names of students who are not
> > enrolled in any class?
>
> Your Word attachment didn't appear to have too many viruses, but here
> are the contents of your gratuitous waste of bandwidth, for those who
> have nothing better to do than do your homework for you:
>
> Student(snum , sname, major,level,age)
> Class(cname, meets_at, room,fid)
> Enrolled(snum, cname)
> Faculty(fid, fname)
>

  1. Assuming a table Lecturer(lnum, lname, fid), and a field lnum in Class

SELECT s.snum, s.sname
FROM Student s, Class c, Enrolled e, Lecturer l WHERE c.cname = e.cname AND s.snum = e.snum AND c.lnum = l.lnum and l.lname = "J. Hill"

b)

No joins needed here:

SELECT s.snum, s.sname
FROM Student
WHERE s.snum NOT IN (SELECT snum FROM Enrolled)

--

Thomas
Received on Wed Mar 22 2000 - 00:00:00 CET

Original text of this message