Subject | selecting concatenated records |
---|---|
Author | Sergio H. Gonzalez |
Post date | 2012-01-16T19:52:08Z |
hello!! I have this situation, and don't know how to solve it...
My table:
ID ORIGINAL_ID
====================
1 NULL
2 1
3 2
4 NULL
5 1
So, the ID 1 has two children (2 and 5) and 2 has one children (3). Of
course, ID 3 could have N children and so on...
What I need is to select all the descendants of a given record. For
instance, I want to select all the records related to ID 1, I would have:
ID ORIGINAL_ID
====================
1 NULL
2 1
3 2
5 1
It sounds that I should use recursion, but I can't figure out how...
Thank you very much!!!!
Sergio.
[Non-text portions of this message have been removed]
My table:
ID ORIGINAL_ID
====================
1 NULL
2 1
3 2
4 NULL
5 1
So, the ID 1 has two children (2 and 5) and 2 has one children (3). Of
course, ID 3 could have N children and so on...
What I need is to select all the descendants of a given record. For
instance, I want to select all the records related to ID 1, I would have:
ID ORIGINAL_ID
====================
1 NULL
2 1
3 2
5 1
It sounds that I should use recursion, but I can't figure out how...
Thank you very much!!!!
Sergio.
[Non-text portions of this message have been removed]