Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: query to trace all parents
PYCTAM wrote:
> Hi,
>
> I have a table with filled out below data:
>
> +------+-----+
> |parent|child|
> +------+-----+
> |A |B |
> |B |C |
> |B |E |
> |C |D |
> |E |F |
> |E |G |
> +------+-----+
>
> So I have to make a query which get all 'parent' values values for
> given child value.
>
> For example :
> -----------------
> If I have to get all parent values for 'D' child., query must get this
> values : C, B, A.
>
> If I have to get all parent values for 'F' child., query must get this
> values : E, B, A.
>
> If I have to get all parent values for 'C' child., query must get this
> values : B, A.
>
> If I have to get all parent values for 'B' child., query must get this
> values : A only.
> -----------------
>
> Is it possible to create a query which will covers all above conditions
> or not using only sql statement without UDF or stored procedures.
>
> Any solutiuons?
>
> Sincerely,
> Rustam Bogubaev
Possible yes. Sensible no. This is just a bad denormalized design that makes no sense. Fix the design and the problem goes away.
-- Daniel A. Morgan http://www.psoug.org damorgan_at_x.washington.edu (replace x with u to respond)Received on Thu Jun 23 2005 - 17:46:25 CDT