There is a table. id | parent_id.
Some parent_id have no parent. How to remove orphans?
For example, there is an entry with parent_id = 10 , but its parent with id = 10 is not. As I understand it, something like
DELETE FROM table t LEFT JOIN table t1 ON t.id = t1.parent_id WHERE t.id IS NULL
parent_id = NULLremain. - Roman