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 18:48:33
Message-ID: 5df248ed-ed48-4de9-bb5c-c25c439f3326@u38g2000pro.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks that did it!

On Aug 6, 11:33 am, pavel(dot)steh(dot)(dot)(dot)(at)gmail(dot)com (Pavel Stehule) wrote:
> Hello
>
> SELECT ... FROM
>   (SELECT ... FROM A
>    UNION ALL
>    SELECT FROM B) s1
>  JOIN C IN C.z = s1.z;
>
> Regards
> Pavel Stehule
>
> 2009/8/6 david.schruth <dschr(dot)(dot)(dot)(at)gmail(dot)com>:
>
>
>
> > 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
>
> > --
> > Sent via pgsql-general mailing list (pgsql-gene(dot)(dot)(dot)(at)postgresql(dot)org)
> > To make changes to your subscription:
> >http://www.postgresql.org/mailpref/pgsql-general
>
> --
> Sent via pgsql-general mailing list (pgsql-gene(dot)(dot)(dot)(at)postgresql(dot)org)
> To make changes to your subscription:http://www.postgresql.org/mailpref/pgsql-general

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Fetter 2009-08-06 18:51:40 Re: JOIN a UNION
Previous Message Tom Lane 2009-08-06 18:43:32 Re: What happens when syslog gets blocked?