realbasic-nug
[Top] [All Lists]

SQL Select

To: "REALbasic NUG" <realbasic-nug at lists dot realsoftware dot com>
Subject: SQL Select
From: "Sean McCollum" <seanmccollum at gmail dot com>
Date: Fri, 28 Jul 2006 09:43:05 -0500
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=O3WU7ZI4hEaFuocE7qwPPY7Z5XaIh7ECaXJh9msQf6Q3ONqjOrsNr1yOxEgBX/GKHvPPjMKJ7D5V3sCCPcAJ635vappcHzbXBEQCpJFwGiShuN4W+K0MWtgxmRw6wuAmM5EqgJ//rW6BqwT3yUuA7b1iSC/Vkoiq+NQd8M2Hcjo=
Hello all,

I hope some of you SQL wizards can help me figure this out:

The statement below works perfectly. I get all student names in the
class with a class id of "A"
SELECT person.name FROM person, class, link WHERE link.pid=person.id
AND link.cid=class.id AND class.id="A"

What I can't figure out is how to get the names of students who are in
TWO or more classes,  "A" and "B", for example. In English: "Select
all students who are in class A as well as class B". Or any
combination of multiple classes: A&C, A,B&C, etc. Can that be
accomplished in one select statement? I haven't been able to do that.

db setup:

Table: person
Columns: id, Name

Table: class
Columns: id, Name

Table: link
Columns: pid, cid

Thanks for any guidance. I'm really stumped.

--
Sean McCollum
Mac OS 10.4.7
RB 2006 r3 Pro
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>