Re: query to trace all parents
Date: Fri, 24 Jun 2005 13:58:51 +0200
Message-ID: <3i2arrFjgnngU2_at_individual.net>
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
>
Another table structure could help Received on Fri Jun 24 2005 - 13:58:51 CEST