The iner select finds duplicates by child_id
The outer with exists finds all records that has to be deletedCode:
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
--> Mysql error 1093 - Can't specify target table for update in FROM clauseCode:
delete tta1 from tezaver_tree_adjacent tta1 ...
How to delete that ?