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

How to chain through tables.

From: Roy Smith <roy_at_popmail.med.nyu.edu>
Date: Fri, 11 Dec 1998 21:00:40 -0500
Message-ID: <roy-1112982100410001@mcsv29-p20.med.nyu.edu>


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 Fri Dec 11 1998 - 20:00:40 CST

Original text of this message

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