The iner select finds duplicates by child_id
select * from tezaver_tree_adjacent tta1 where exists
from tezaver_tree_adjacent tta
where tta.CHILD_ID = tta1.CHILD_ID
group by tta.CHILD_ID
having count(tta.CHILD_ID) > 1
The outer with exists finds all records that has to be deleted
delete tta1 from tezaver_tree_adjacent tta1 ...
--> Mysql error 1093 - Can't specify target table for update in FROM clause
How to delete that ?