sql 查找重复数据,并且重复数据有子集
SELECT A.* FROM comm_department A INNER JOIN ( select path,count(*) as count from comm_department group by path having count>1 ) B ON B.path=A.path WHERE EXISTS(SELECT * FROM comm_department C WHERE C.parent_id=A.id)
SELECT A.* FROM comm_department A INNER JOIN ( select path,count(*) as count from comm_department group by path having count>1 ) B ON B.path=A.path WHERE EXISTS(SELECT * FROM comm_department C WHERE C.parent_id=A.id)