Problem with querying record with multiple records in a joined table
Posted on 2009-05-13
We have two tables, Names and Prefs. Prefs have fields ID (key back to Names), method and request. This is how we track the Do Not Contact lists. Someone can have method = 'Fax' and request = 'Opt-Out' and when we pull a query for fax, this person will be skipped.
The problem is a person may have more than one Prefs record for other requests like Opt-Out of Email and Opt-In Phone etc. So for same person in Names table there may be mulitple Prefs table records.
So, when we set up a SQL query joining the Names and Prefs tables together by ID, we can put in a WHERE statement of method<>'Fax' and request<>'Opt-Out' but it will still pull the Names record if there is another entry in the Prefs table.
So, not sure how to word this question. But how do we pull a query with 2 tables (Names and Prefs) where we don't want the Names record if it has specific record in Prefs table (i.e. Opt-Out of Fax), barring all other Prefs records attached to that Names record?
Thanks in advance.