Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Hierarchical queries: getting parent-grandparent
I'm trying to write a query on oracle 8.1.7 that will give me
grandparent-child assocations. For example, if this is my table:
parent child
1 2 2 3 3 4
I want a query that shows all descendant of "parent". Such a query should produce:
parent child
1 2 2 3 3 4 1 3 1 4 2 4
I've tried using oracle hierarchical queries (START and CONNECT BY), but they don't give grandparent-child tuples. For example, here's what I get with this query:
SELECT * FROM mytable
START WITH parent_id = 1
CONNECT BY PRIOR child = parent;
PARENT CHILD
---------- ----------
1 2 2 3 3 4
(To reply to me directly, please remove the unspam string from my email) Received on Mon Jul 15 2002 - 20:22:35 CDT
![]() |
![]() |