Sean,

Hi! I think you need to use the IN keyword in your select statement, thus :

SELECT person.name FROM person, class, link WHERE link.pid=person.id
AND link.cid=class.id AND class.id IN ("A", "B")

This is 'better' than writing the alternate solution using OR :
SELECT person.name FROM person, class, link WHERE link.pid=person.id
AND link.cid=class.id AND (class.id = "A" OR class.id = "B")

Regards,

Narinder.
-- 

 ___________________________________________
| Narinder Chandi,
| ToolBox Systems Limited,
| Surrey, England, UK.
| tel/fax : +44 (0)1372 720117
| mobile  : +44 (0)7973 512495
| skype   : NarinderChandi
| www     : http://www.toolbox.uk.com
|___________________________________________
|    Consultancy * Development * Support
|    * 4D Solutions Partner since 1998 *
|___________________________________________


on 28/7/06 16:58, [EMAIL PROTECTED] at
[EMAIL PROTECTED] wrote:

> Subject: SQL Select
> From: "Sean McCollum" <[EMAIL PROTECTED]>
> Date: Fri, 28 Jul 2006 09:43:05 -0500
> 
> 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>

Reply via email to