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

Home -> Community -> Usenet -> c.d.o.server -> Re: Challenging query: traverse a tree using SQL?

Re: Challenging query: traverse a tree using SQL?

From: Vijay Darekar <vd62020_at_glaxowellcome.com>
Date: 1998/01/16
Message-ID: <34BFD6C0.67EE@glaxowellcome.com>#1/1

L. Tseng wrote:
>
> Hi, SQL experts,
>
> does anyone know if traversing a tree can be done using sql?
> For example:
>
> nodeid parentnodeid level
>
> 3 3 1
> 4 3 2
> 8 3 2
> 2 4 3
> 1 4 3
> 9 8 3
> 7 8 3
> 6 2 4
> 10 7 4
>
> Tree structure:
> 3
> 4 8
> 2 1 9 7
> 6 10
>
> Question:
> Given a node id=4, how can I get a list of child node ids including itself
> order by level?
> 4
> 1
> 2
> 6
>
> Any help will be greatly appreciated.
>
> Leslie
> --
> =-=-=-=-=-=-=-=-=-=-=
> Leslie Tseng
> lesliet_at_writeme.com
> =-=-=-=-=-=-=-=-=-=-=

select nodeid
from tables
start with nodeid = 4
connect by nodeid = parentid Received on Fri Jan 16 1998 - 00:00:00 CST

Original text of this message

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