Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
One table from a database, which has the parent in the same table. But a entry can have more than one parent. It's nowhere defined how many parents, but what I see, should there be not more than 15. How can I get the full path for each entry? At the end I should get for each entry the whole path.
A example from the table
ID | part of path | Parent ID |
1 | root | |
2 | fruits | 1 |
3 | banana | 2 |
4 | apple | 2 |
5 | yellow | 3 |
6 | vegetables | 1 |
7 | potato | 6 |
I need at the end
ID | full path |
1 | root |
2 | root/fruits |
3 | root/fruits/banana |
4 | root/fruits/apple |
5 | root/fruits/banana/yellow |
6 | root/vegetables |
7 | root/vegetables/potato |
One self join is no problem, but this... I really need help.
thanks in advance,
Tina
try hierarchy keyword
Hierarchy(ID,ParentID,partofpath)
LOAD * INLINE [
ID, partofpath, ParentID
1, root
2, fruits, 1
3, banana, 2
4, apple, 2
5, yellow, 3
6, vegetables, 1
7, potato, 6
];
try hierarchy keyword
Hierarchy(ID,ParentID,partofpath)
LOAD * INLINE [
ID, partofpath, ParentID
1, root
2, fruits, 1
3, banana, 2
4, apple, 2
5, yellow, 3
6, vegetables, 1
7, potato, 6
];
Thank you very much, it's exactly what I searched.