I need to explain better.
Say you have three tables, the first is your persons table, the second is
just to hold ID's from the first and third table (to give you a many-to-many
relationship), and the third table has classes, with 2 fields, classID and
class name.
So one class may have many people and one person may have many classes. The
second table just links them together, ClassID and PersonID.
So now you have a classID and you want to find all the people who are not in
this class. You have to query the second table to find who is in the class,
and then you want to query the People table but only return the people not
in you first query.
Is that the best way to do it? If so, how do you do it. If not, what is?
> Hi John,
>
[quoted text clipped - 37 lines]
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
Pritcham - 25 Aug 2006 14:25 GMT
Hi
Using your example something like the following would get the results
you need:
Select * From person Where PersonID Not In(SELECT PersonClass.PersonID
FROM PersonClass
WHERE (((PersonClass.ClassID)=2)));
This has been run against a mockup DB with 3 tables: Person (PK:
PersonID, Name), Class(PK: ClassID, Classname), PersonClass(PK:
PersonID + ClassID).
Basically the bracketed Select (subquery) is selecting the 'who is in
class 2' results, the first part of the query is finding people in the
person table who are NOT in the results of that (first) query
Hope that helps
Martin
> I need to explain better.
>
[quoted text clipped - 54 lines]
> > This posting is provided "AS IS" with no warranties, and confers no
> > rights.
John - 25 Aug 2006 18:40 GMT
Yeah, I think its working. Thanks for your help.
> Hi
>
[quoted text clipped - 89 lines]
>> > This posting is provided "AS IS" with no warranties, and confers no
>> > rights.