How in 1 request to get all branch with childs?

Having table with fields id, parent_id, title (mysql5) how can I with 1 request to get all branch with childs
of parent N ? I mean grandchilds and deeper too…


Relational databases are not designed for recursive problems but at the end it is of course possible.

Here is a very good explanation of the possibilities and pro and contra of them:

1 Like

that is pretty good

it’s too bad @mstdmstd is on MySQL 5, because of course the best solution uses the recursive CTE

here’s my article on one of the other methods, using self-joins – Categories and Subcategories

regarding depth of the tree, i’d like to draw attention to these three points –