So i have this table A:
color ID MODEL ----------------------------- red | 10 | HONDA blue | 10 | TOYOTA red | 15 |
I think your expected result should just be red 15. Red 30 would not qualify because of yellow 30, which shares the same id. Check out my code:
SELECT t.id, t.color FROM t INNER JOIN (SELECT id FROM t GROUP BY id HAVING COUNT(*) = 1) sub ON t.id = sub.id WHERE color = 'red' OR color = 'blue'