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)