I'm trying to build a form to do ad-hoc querys for a project i'm working on and I have a question about this query i'm trying to build.
I have a feeling i should know the answer to this.. so forgive me If it's rather obvious..
I have a table full of Contacts(people) and a table to link them to various categories that they may belong to..
tblContacts, tbl_contact_category, tblCategories
I'd like to write a query that pulls all of the contacts that are in a certian category yet make sure they do not belong to another of the categories..
I have tried a number of things.. this the latest one..
Code: Select all
SELECT DISTINCT c.* FROM tblcontacts c
LEFT OUTER JOIN tbl_contact_category cc0 on c.intContact_ID = cc0.intContactID
LEFT OUTER JOIN tbl_contact_category cc1 on c.intContact_ID = cc1.intContactID
WHERE (cc0.intCategoryID = 15)AND NOT (cc1.intCategoryID = 12)Can someone offer me some assistance please. This has give me a headache
Thanks
Will
