I have a table design like so
person_id | department 1 | a 1 | b 2 | a 2 | c 3 | b 3 |
SELECT person_id FROM yourTable WHERE department = 'a' OR department = 'b' GROUP BY person_id HAVING COUNT(DISTINCT department) = 2
Note: The DISTINCT is only needed if a person can be a member of the same department more than once.