3

I have a table like follow:

my table

I want to select items that it's active column is 1 and all children recursively. result will be like follow:

a,b,c,d

How can I do it?

Salman A
  • 248,760
  • 80
  • 417
  • 510
Rahman
  • 321
  • 2
  • 21
  • 2
    Possible duplicate of [What are the options for storing hierarchical data in a relational database?](https://stackoverflow.com/questions/4048151/what-are-the-options-for-storing-hierarchical-data-in-a-relational-database). To be honest your schema sucks and the query will be extremely inefficient. Especially with high number of descendants. – emix Feb 25 '19 at 08:31
  • MySQL version?? – Salman A Feb 25 '19 at 08:36
  • MySql version is: 5.7 – Rahman Feb 25 '19 at 08:38
  • If you upgrade to MySQL-8.0 you have recursive CTE which make this quite easy. What happens to the output where there is more than one child? – danblack Feb 25 '19 at 08:52
  • all of children will be as result. – Rahman Feb 25 '19 at 08:56
  • no answer :-( ? – Rahman Feb 25 '19 at 09:08

0 Answers0