Show parent caregories using group_concat

I have this categories structure for category and parent:

|   id  |   title   |      parent_id     |
|   1   |  cat1   |             0           |
|   2   |  cat2   |             1           |
|   3   |  cat3   |             2           |
|   4   |  cat4   |             0           |

I need to show output using GROUP_CONCAT and SEPERATOR ' >' like this:

cat 1
cat 1 > cat 2
cat 1 > cat 2 > cat 3
cat 4 

How do can i generate this? thanks for any help.

You will find the answer hereā€¦
https://www.mysqltutorial.org/mysql-adjacency-list-tree/

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.