I am working with a filter that I can use after the search so that way I created a table in the database and insert some category and its sub categories and now I want to combine all of the to make a tree like structure. But I am stuck with this
Now How can I achieve this?
[
{
"parent_category": "Recruitment",
"category_name": "Job description"
},
{
"parent_category": "Recruitment",
"category_name": "Forms"
},
{
"parent_category": "Performance management system",
"category_name": "Job description"
},
{
"parent_category": "Exit",
"category_name": "Job description"
}
]
to this type of result :
[
{
"parent_category": "Recruitment",
"category_name": "Job description, Forms"
},
{
"parent_category": "Performance management system",
"category_name": "Job description"
},
{
"parent_category": "Exit",
"category_name": "Job description"
}
]
Without using a long type of for loop because it consume more time.