I have a table with the following structure:
CHILD_ID | PARENT_ID
Both columns are integers.
I am trying to get all ancestors for a given ‘node’. I have the top most id and I would like to select a table containing all the ids of the children.
CHILD_ID | PARENT_ID
1 2
6 12
2 3
3 4
9 82
Finding the ancestors for 4
Should return
ID
3
2
1
How would this be done in oracle?
Can it be done without a stored procedure?
As always, thank you in advanced for your time.
To meet your output expectations, the query could be like this: