これを試してください- SELECT clientid FROM clients GROUP BY clientid HAVING COUNT(*) = COUNT(IF(PageID = 3, PageID, NULL));