Selecting only records where both of two values exist (2 Viewers)

With those database constraints I was wrong. Cheeky's solution will work. Sorry.
 
SQL:
SELECT    c.*
FROM     Contacts c
WHERE EXISTS (SELECT 'x'
                FROM tblContact_Categories cc1  
                INNER JOIN tblCategoryTypes t
                    ON cc1.CategoryTypeID = t.CategoryTypeID
                WHERE t.[Category Type]  = 'car'
                AND cc1.ContactID = c.ContactID)
AND EXISTS (SELECT 'x'
                FROM tblContact_Categories cc1  
                INNER JOIN tblCategoryTypes t
                    ON cc1.CategoryTypeID = t.CategoryTypeID
                WHERE t.[Category Type]  = 'bike'
                AND cc1.ContactID = c.ContactID)
Winner.
 

Users who are viewing this thread

Back
Top Bottom