Many-to-many relationship query question...

D

Dan

Hi - I have a query question that I hope someone would have some insight on.
I have the three tables shown below with the following fields:

tblContacts: NameID, Name
tblContactsCategories: NameID, CategoryID
tblCategories: CategoryID, Category

It's a simple many-to-many relationship between contact names and categories
I can group them in. Is there a way to make a query staement that basically
will list out contacts that don't belong to any categories (i.e. contacts
from tblContacts that are not in tblContactsCategories)?

Thanks so much for any ideas -

Dan
 
M

Marshall Barton

Dan said:
Hi - I have a query question that I hope someone would have some insight on.
I have the three tables shown below with the following fields:

tblContacts: NameID, Name
tblContactsCategories: NameID, CategoryID
tblCategories: CategoryID, Category

It's a simple many-to-many relationship between contact names and categories
I can group them in. Is there a way to make a query staement that basically
will list out contacts that don't belong to any categories (i.e. contacts
from tblContacts that are not in tblContactsCategories)?


SELECT tblContacts.NameID, tblContacts.Nane
FROM tblContacts LEFT JOIN tblContactsCategories
On tblContacts.NameID = tblContactsCategories.NameID
WHERE tblContactsCategories.NameID Is Null

This should be what you get by using the unmatched query
wizard.
 
D

Dan

Great, thanks so much! I knew it could be done - just couldn't find out how.
I really appreciate your help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top