Say I have the following structure in a table:
+-------------+----------------+-----------+
| category_id | name | parent_id |
+-------------+----------------+-----------+
| 1 | foo | 0 |
| 2 | bar | 0 |
| 3 | baz | 1 |
| 4 | test | 2 |
| 5 | test1 | 3 |
| 6 | test2 | 5 |
+-------------+----------------+-----------+
Does anyone have any pointers to achieve the following output:
foo
bar
foo > baz
bar > test
baz > test1
baz > test 1 > test2
I’m open to changing my schema if it helps, not sure if it is the best method to store the data?
Thanks
maybe you want to have a look at nested sets