I have the following table:
categoryID categoryName parentID
categoryID | categoryName | parentID |
---|---|---|
6 | Category6 | 0 |
7 | Category7 | 0 |
12 | Category12 | 6 |
13 | Category13 | 7 |
How can I get the following order:
categoryID | categoryName | parentID |
---|---|---|
6 | Category6 | 0 |
12 | Category12 | 6 |
7 | Category7 | 0 |
13 | Category13 | 7 |
That is each "child" category to go under it's parent?
I tried with different select and ordering, group by queries, but nothing seems to work.
This question has been marked as duplicate, but it is not. Solution posted on: How to create a MySQL hierarchical recursive query? does not help me, since it shows record for selected category, and I want the whole tree.