Re: JOIN a UNION

From: "david(dot)schruth" <dschruth(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: JOIN a UNION
Date: 2009-08-06 17:53:05
Message-ID: a718dbdf-62e5-4f5e-8dff-91fbb219c638@y4g2000prf.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I just realized what I posted was perfectly valid SQL. The following
is more what I had in mind:

(SELECT x,y,z FROM A
UNION
SELECT x,y,z FROM B)
AB JOIN C ON C.z = AB.z

This version certainly does throw an error.

Basically I'm wondering if there is a way to get Postgres to treat the
result of a UNION as a table on which I could perform subsequent
operations (like a JOIN).

On Aug 6, 10:43 am, "david.schruth" <dschr(dot)(dot)(dot)(at)gmail(dot)com> wrote:
> Simple question:
>
> Is there a way to do something like the following:
>
> SELECT x,y,z FROM A
> UNION
> SELECT x,y,z FROM B
> JOIN C ON C.z = B.z
>
> Thanks,
>
> Dave

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Stehule 2009-08-06 18:30:52 Re: Empty Updates, ON UPDATE triggers and Rules
Previous Message david.schruth 2009-08-06 17:43:43 JOIN a UNION