Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> How to chain through tables.
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