Click to See Complete Forum and Search --> : query help


tron
05-01-2003, 12:56 PM
I was hoping someone could help me with a query...I am thinking that I need an 'IN' statement, however I am not sure. Here is what my tables look like:

tblGroups
---------
group
---------
groupA
groupB
groupC

tblBridge
---------
user | group
---------
userA | groupA
userA | groupB
userB | groupC
userC | groupA

Basically I want my query to show only the groups that userA is NOT a member of...which is just gorupC. Any ideas?

slimdave
05-01-2003, 01:33 PM
select group from tblGroups
where group not in
(
select group by tblBridge where user='userA'
)

... or ...

select group from tblGroups
minus
select group by tblBridge where user='userA'

... or ...

select group from tblGroups g
where not exists
(
select group by tblBridge t where user='userA'
and t.group = g.group
)

... or ...

some other methods.



I like the minus operator.