I have a db of contacts that includes a linking table to match contacts to the groups each is in. I need to be able to query for contacts that are in a specified group AND in another specified group. My query instead returns all contacts in [SelectGroup2]. Is there a way to make this work? Thanks in advance!
SELECT tblContacts.[FirstName], tblContacts.[LastName], tblContacts.Company, tblContacts.Email, tblContacts.Type, tblGroups.Group
FROM tblGroups INNER JOIN (tblContacts INNER JOIN tblContGrpLink ON tblContacts.ContactID = tblContGrpLink.Contact) ON tblGroups.GroupID = tblContGrpLink.Group
WHERE (((tblGroups.Group)=[Select Group 2])) AND EXISTS
( SELECT tblGroups.Group
FROM tblGroups AS GroupList INNER JOIN (tblContacts INNER JOIN tblContGrpLink ON tblContacts.ContactID = tblContGrpLink.Contact) ON GroupList.GroupID = tblContGrpLink.Group
WHERE (((GroupList.Group)=[SelectGroup1])));
SELECT tblContacts.[FirstName], tblContacts.[LastName], tblContacts.Company, tblContacts.Email, tblContacts.Type, tblGroups.Group
FROM tblGroups INNER JOIN (tblContacts INNER JOIN tblContGrpLink ON tblContacts.ContactID = tblContGrpLink.Contact) ON tblGroups.GroupID = tblContGrpLink.Group
WHERE (((tblGroups.Group)=[Select Group 2])) AND EXISTS
( SELECT tblGroups.Group
FROM tblGroups AS GroupList INNER JOIN (tblContacts INNER JOIN tblContGrpLink ON tblContacts.ContactID = tblContGrpLink.Contact) ON GroupList.GroupID = tblContGrpLink.Group
WHERE (((GroupList.Group)=[SelectGroup1])));