Re: how to sql query this?

From: NoName <nobody_at_nowhere.com>
Date: Thu, 21 Oct 2004 10:12:05 +0200
Message-ID: <cl7qln$ht7$1_at_grillo.cs.interbusiness.it>


> I have a table that contains data keys similar the following, where each
> letter is a key to an address
  [...snipped...]
> if i pass in a key such as "a" how can i return the items that are
connected
> to "a" both directly & indirectly?
  [...snipped...]
> the parent key is always in col1, the child in col2

Hello,
have a look at "Hierarchical query" chapter in your Oracle manual.

your problem can be solved with a select like this one:

SELECT * from MyTable
CONNECT BY PRIOR col2=col1
START WITH col1='a';

This return all items in a "tree", starting from the one whose parent has "a" value.

Regards Received on Thu Oct 21 2004 - 10:12:05 CEST

Original text of this message