> Something like this, perhaps...
> SELECT
> tableA.id,tableA.name,tableA.addr,tableA.city,tableA.state,tableA.zip
> FROM tableA,tableB
> WHERE tableA.id=tableB.tableAid
> AND (tableB.group='eagles' OR tableB.group='moose' OR
> tableB.group='elks');
> (No guarantees as I've not tried this...)
> ~Gary
This statment returns a list of users in any one of the groups... There are
two other (at least) statments that will return users in all three groups...
SELECT A.Name
FROM A INNER JOIN
B ON A.ID = B.tableAid
WHERE (B.[Group] = 'elks' OR B.[Group] = 'moose' OR B.[Group] = 'eagles'))
GROUP BY A.Name
HAVING (COUNT(A.Name) = 3)
This uses the 'or' criteria...
SELECT A.Name
FROM A INNER JOIN
B ON A.ID = B.tableAid
WHERE (B.[Group] IN ('elks', 'moose', 'eagles'))
GROUP BY A.Name
HAVING (COUNT(A.Name) = 3)
This uses a 'nested select'...
The key is making sure that each user is in all three groups, not just
one...
-----Original Message-----
From: Gary Maltzen
To: Gary S. Mackay; ">ale@ale.org
Sent: 5/15/00 3:58 PM
Subject: Re: [ale] SQL statement problem
Gary,
So what you *really* want is an -OR- condition...
a member of elks
-OR-
a member of moose
-OR-
a member of eagles
----- Original Message -----
> How would I create an SQL statement for the 'AND' condition? Let me
explain...
> I have two tables, tableA (id,name,addr,city,state,zip) and tableB
> (tableAid,group). Table A is just a list of names, and table B is a
list
of
> groups that each person in table A belongs to. How do I create a SQL
statement
> that will show everyone in table A that has three particular records
in
table
> B? (In english "Show me everyone that is a member of the
elks,moose,and
eagles
> clubs") It's easy to show everyone that is a member of any one of the
> requested groups, but how do I show people that have all three records
in
> table B?
--
To unsubscribe: mail ">majordomo@ale.org with "unsubscribe ale" in message
body.
--
To unsubscribe: mail ">majordomo@ale.org with "unsubscribe ale" in message body.