我在生成针对此问题的查询时遇到问题。
我有这张小桌子
Tasks(employee_name, task) Sample Data: Tasks ------------------ Joe | taskA Joe | taskB Ted | taskA Jim | taskB Ray | taskA Ray | taskB John| taskA Tim | taskC
我需要找到任务完全相同的所有成对的员工。
例如,使用结果集上方的数据应为:
--------------------- employee1 | employee2 --------------------- Joe | Ray Ted | John
我正在为数据库使用mySQL。谢谢!
select a.employee_name,b.employee_name from tasks as a, tasks as b where a.employee_name>b.employee_name group by a.employee_name,b.employee_name having group_concat(distinct a.task order by a.task)=group_concat(distinct b.task order by b.task)