SELECt person_idFROM yourTableWHERe department = 'a' OR department = 'b'GROUP BY person_idHAVINg COUNT(DISTINCT department) = 2
注意:仅当一个人可以多次成为同一部门的成员时,才需要使用DISTINCT。

SELECt person_idFROM yourTableWHERe department = 'a' OR department = 'b'GROUP BY person_idHAVINg COUNT(DISTINCT department) = 2
注意:仅当一个人可以多次成为同一部门的成员时,才需要使用DISTINCT。