Re: WITH and WITH RECURSIVE in single query

From: David Johnston <polobo(at)yahoo(dot)com>
To: Maxim Boguk <maxim(dot)boguk(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: WITH and WITH RECURSIVE in single query
Date: 2011-12-05 03:45:18
Message-ID: 8F745C3E-E709-4491-902C-DF9A84958B5B@yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Dec 4, 2011, at 22:28, Maxim Boguk <maxim(dot)boguk(at)gmail(dot)com> wrote:

> Hi.
>
> Is here any way to combine WITH and WITH RECURSIVE into single query?
>
> Something like:
>
> WITH t AS (some complicated select to speed up recursive part),
> RECURSIVE r AS
> (
> ...
> UNION ALL
> ...
> )
>
> ?
>
> --
> Maxim Boguk
> Senior Postgresql DBA.

WITH RECURSIVE q1 As (), q2 AS () ...

Add RECURSIVE after the WITH; it then applies to any/all the CTEs.

Look at the specification (and description) in the SELECT documentation closely.

David J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Maxim Boguk 2011-12-05 03:58:19 Re: WITH and WITH RECURSIVE in single query
Previous Message Maxim Boguk 2011-12-05 03:43:43 Questions about setting an array element value outside of the update