I have a hierarchy system setup that stores the level and parent ID of the item in a database. What I am trying to figure out is how would I go about finding all the child rows of the one the user select. Here is a sample of the table structure:
+----+---------+----------+-------+
| Id | label | parentid | level |
+----+---------+----------+-------+
| 1 | honda | 0 | 1 |
| 2 | accord | 1 | 2 |
| 3 | civic | 1 | 2 |
| 4 | element | 1 | 2 |
| 5 | v4 | 2 | 3 |
| 6 | v6 | 2 | 3 |
+----+---------+----------+-------+
So, if someone deletes honda
, how would I go about deleting everything down the hierarchy? The database will only ever have down to a level 3.