Answer the question
In order to leave comments, you need to log in
How to select a parent and all children?
There is a table category :
You need to select the parents and all child categories . I am using the following query:
SELECT t1.name AS parent, t2.name as children
FROM category AS t1
LEFT JOIN category AS t2 ON t2.parent_id = t1.id
WHERE t1.parent_id IS NULL
ORDER BY t1.id
Answer the question
In order to leave comments, you need to log in
I would like to combine all the children into one element.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question