I have one single table where the parentId column can be 0 for top level items or a number for items belonging to other items. There's no limit to how deep the nesting can go.
id parentId title
-------------------------
1 0 Item1
2 1 Item11
3 2 Item22
4 0 Item2
5 4 Item21
What I want is that every time I delete one item, every child and child of a child is deleted, until no item has a parentId of an item that does not exist.
I know I can loop through the records and query DELETE starting from the bottom child but I wonder if this can be done only with a SQLite command