Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Hierarchy Query

810903Nov 5 2010 — edited Nov 5 2010
Hi Everyone,

I have a small requirement regarding hierarchy query which goes as below....

I have a table RELATION which has a child - parent relation.

create table relation
( parent number,
child number primary key
);

And the data will be like.

Parent Child
A B
A c
B D
B E
D F
C G

Now if i start from A i need the full path from A to its sons(and son of sons) all the possible path. can any one please help

me in writing a query which can give as the below output.

For A the output shoud be two rows as below:
A->B->D->F
A->B->E

For B as a parent it should be:
B->D->F
B->E

Please reply

Thanks in advance,
Sartaj

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Dec 3 2010
Added on Nov 5 2010
8 comments
901 views