I have a table representing the family tree. It has fields ID
, NAME
, LEVEL
, PARENT_ID
.
And the column PARENT_ID
is the foreign key and refers to column ID
of this table. How can I get a list of all (any level to the bottom of the hierarchy) children knowing only the ID
of specific person's row?
I need to get it in a single query without using a stored procedure calls. Please help make this the most well.
For example, if ID
is 7 then result should be:
I use MySQL-5.1.
Edit: If the original issue has not solution, maybe is there solution when maximum level equal to 5 ?