I have a table design like so
person_id | department 1 | a 1 | b 2 | a 2 | c 3 | b 3 |
You can also achieve this with a subquery:
SELECT person_id FROM table t1 WHERE t1.department = 'a' AND EXISTS (SELECT 1 FROM table t2 WHERE t2.department = 'b' AND t1.person_id = t2.person_id`)