Re: Getting to grips with Recursive CTEs. - Mailing list pgsql-novice

From Pól Ua Laoínecháin
Subject Re: Getting to grips with Recursive CTEs.
Date
Msg-id CAF4RT5TxSd8wyEmYJkzuohcwGStvvyct=EKeOOsxc0_A6QaYvQ@mail.gmail.com
Whole thread Raw
In response to Re: Getting to grips with Recursive CTEs.  ("Miguel Beltran R." <yourpadre@gmail.com>)
List pgsql-novice
Hola Miquel,

y gracias por tu contribución,

> You are not using a recursive function because it is needed to call the table "rcte" in the UNION ALL
> But it will fail because t3.parent is null at the beginning, so try this another one

> WITH rcte (child, parent) AS
> (
>   SELECT parent AS child, '' AS parent FROM tree t1
>     WHERE Parent NOT IN (SELECT child FROM tree)
>   UNION ALL
>   SELECT t2.child, t3.parent FROM tree t2
>   JOIN rcte t3 ON t2.parent >= t3.parent
> )

> I haven't tried.

That's great - I've played around with it a wee bit - still have a lot
to learn! :-)

Haven't had too much time - but I think it's slowly dawning on me.

Best regards,

Pól...



pgsql-novice by date:

Previous
From: Potvin, Jérémi
Date:
Subject: RE: Security question
Next
From: Pól Ua Laoínecháin
Date:
Subject: Re: Getting to grips with Recursive CTEs.