From: | Avi Weinberg <AviW(at)gilat(dot)com> |
---|---|
To: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
Cc: | "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | RE: Multiple SELECT statements Using One WITH statement |
Date: | 2022-01-20 14:42:13 |
Message-ID: | DB9PR07MB7180193C517B713F3983700CCB5A9@DB9PR07MB7180.eurprd07.prod.outlook.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Thanks David for the reply, but my question was a little different.
I know I can have multiple CTE queries like you showed, but I want to have one single WITH query, and use it in multiple queries, not just by one query the directly proceed the CTE.
Why do I need to execute the CTE query twice if I have two queries that wants to use it?
Thanks
From: David G. Johnston [mailto:david(dot)g(dot)johnston(at)gmail(dot)com]
Sent: Thursday, January 20, 2022 2:58 PM
To: Avi Weinberg <AviW(at)gilat(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Multiple SELECT statements Using One WITH statement
On Thursday, January 20, 2022, Avi Weinberg <AviW(at)gilat(dot)com<mailto:AviW(at)gilat(dot)com>> wrote:
Hi,
Can I have multiple select statements using one WITH statement?
WITH t AS (
Select A, B from …
)
SELECT A into tableA FROM t where ….;
SELECT B into tableB FROM t where ….;
With q1 as (), q2 as (), q3 as () main_query
David J.
IMPORTANT - This email and any attachments is intended for the above named addressee(s), and may contain information which is confidential or privileged. If you are not the intended recipient, please inform the sender immediately and delete this email: you should not copy or use this e-mail for any purpose nor disclose its contents to any person.
From | Date | Subject | |
---|---|---|---|
Next Message | Josef Šimánek | 2022-01-20 15:13:31 | Re: Multiple SELECT statements Using One WITH statement |
Previous Message | Ekaterina Amez | 2022-01-20 14:31:06 | Query much slower from php than psql or dbeaver |