Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Connect By hierarchy problem

Connect By hierarchy problem

From: Mike C <michaeljc70_at_hotmail.com>
Date: 17 Oct 2006 08:05:01 -0700
Message-ID: <1161097500.469229.311400@m7g2000cwm.googlegroups.com>


I have a simple table with a hierarchical structure:

CREATE TABLE relation (parent_id number, child_id number);

INSERT INTO relation values (10,3);
INSERT INTO relation values (3,2);
INSERT INTO relation values (2,1);
INSERT INTO relation values (10,5);
INSERT INTO relation values (14,11);
INSERT INTO relation values (11,17);

I need to a query to return a results that lists every child and it's direct and not direct parent (it's parents parent and so on), Having the level would be nice too For example, I want this back:

Parent_id Child_id

10            3
3              2
10            5
14            11
11            17
10            2
14            17
2              1
3               1
10             1

I can't seem to get CONNECT BY to do this. Received on Tue Oct 17 2006 - 10:05:01 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US