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: How to chain through tables.

Re: How to chain through tables.

From: John Koo <johnkoo_at_i-wave.net>
Date: Sat, 12 Dec 1998 18:59:19 +0800
Message-ID: <36724C87.73AB1BC0@i-wave.net>


Are you looking for the LEVEL pseudo code ?

Roy Smith wrote:

> I've got a table, call it foo, which looks sort of like this:
>
> id name parent
> 1 foo 2
> 2 bar 4
> 3 other 5
> 4 baz NULL
> 5 stuff NULL
> 6 xyz 2
>
> Each row in the table is essentially a node in a tree. I want to get all
> the rows which trace the chain from a given row, through the parent
> pointers, to the root, i.e. starting with 1, I want to get back rows 1, 2,
> and 4. Starting with 6, I want to get 6, 2, and 4. And so on. Is there
> a single SQL statement I can write to execute that query?
Received on Sat Dec 12 1998 - 04:59:19 CST

Original text of this message

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