pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedWhat is Syntax for multiple FULL OUTER JOINS?
3+ messages / 2 participants
[nested] [flat]
* What is Syntax for multiple FULL OUTER JOINS?
@ 2002-03-20 03:28 Patrick Hatcher <PHatcher@macys.com>
0 siblings, 1 reply; 3+ messages in thread
From: Patrick Hatcher @ 2002-03-20 03:28 UTC (permalink / raw)
To: pgsql-sql
Is it possible to do a full outer join on 3 or more queries? I figured out
how to do 2, but I get an error message when trying to do three
Example:
(works)
select coalesce(a.f1, b.f1) as col_1, b.f2 as col_2
from
(select f1, f2 from table1 where f3 =1) a
FULL OUTER JOIN
(select f1, f2 from table1 where f3 =2) b
on a.f1 = b.f1
(does not work)
select coalesce(a.f1, b.f1,c.f1) as col_1, b.f2 as col_2, c.f2 as col_3
from
(select f1, f2 from table1 where f3 =1) a
FULL OUTER JOIN
(select f1, f2 from table1 where f3 =2) b
FULL OUTER JOIN
(select f1, f2 from table1 where f3 =3) c
on a.f1 = b.f1and a.f1 = c.f1
TIA
Patrick Hatcher
Macys.Com
Legacy Integration Developer
415-932-0610 office
HatcherPT - AIM
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: What is Syntax for multiple FULL OUTER JOINS?
@ 2002-03-20 04:08 Stephan Szabo <sszabo@megazone23.bigpanda.com>
parent: Patrick Hatcher <PHatcher@macys.com>
0 siblings, 0 replies; 3+ messages in thread
From: Stephan Szabo @ 2002-03-20 04:08 UTC (permalink / raw)
To: Patrick Hatcher <PHatcher@macys.com>; +Cc: pgsql-sql
On Tue, 19 Mar 2002, Patrick Hatcher wrote:
> Is it possible to do a full outer join on 3 or more queries? I figured out
> how to do 2, but I get an error message when trying to do three
>
>
> Example:
>
> (works)
> select coalesce(a.f1, b.f1) as col_1, b.f2 as col_2
> from
> (select f1, f2 from table1 where f3 =1) a
> FULL OUTER JOIN
> (select f1, f2 from table1 where f3 =2) b
> on a.f1 = b.f1
>
> (does not work)
> select coalesce(a.f1, b.f1,c.f1) as col_1, b.f2 as col_2, c.f2 as col_3
> from
> (select f1, f2 from table1 where f3 =1) a
> FULL OUTER JOIN
> (select f1, f2 from table1 where f3 =2) b
> FULL OUTER JOIN
> (select f1, f2 from table1 where f3 =3) c
> on a.f1 = b.f1and a.f1 = c.f1
You need separate on clauses for each join:
select ...
from (
(select f1, f2 from table1 where f3=1) a
full outer join
(select f1, f2 from table1 where f3=2) b
on a.f1=b.f1)
full outer join
(select f1,f2 from table1 where f3=3) c
on a.f1=c.f1
should do it I think.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: What is Syntax for multiple FULL OUTER JOINS?
@ 2002-03-20 17:04 Patrick Hatcher <PHatcher@macys.com>
0 siblings, 0 replies; 3+ messages in thread
From: Patrick Hatcher @ 2002-03-20 17:04 UTC (permalink / raw)
To: "Stephan Szabo <sszabo" <sszabo@megazone23.bigpanda.com>; +Cc: pgsql-sql
Thanks that did it.
Patrick Hatcher
Macys.Com
Legacy Integration Developer
415-932-0610 office
HatcherPT - AIM
Stephan Szabo
<sszabo@megazone23.big To: Patrick Hatcher <PHatcher@macys.com>
panda.com> cc: <pgsql-sql@postgresql.org>
Subject: Re: [SQL] What is Syntax for multiple FULL OUTER
03/19/2002 08:08 PM JOINS?
On Tue, 19 Mar 2002, Patrick Hatcher wrote:
> Is it possible to do a full outer join on 3 or more queries? I figured
out
> how to do 2, but I get an error message when trying to do three
>
>
> Example:
>
> (works)
> select coalesce(a.f1, b.f1) as col_1, b.f2 as col_2
> from
> (select f1, f2 from table1 where f3 =1) a
> FULL OUTER JOIN
> (select f1, f2 from table1 where f3 =2) b
> on a.f1 = b.f1
>
> (does not work)
> select coalesce(a.f1, b.f1,c.f1) as col_1, b.f2 as col_2, c.f2 as col_3
> from
> (select f1, f2 from table1 where f3 =1) a
> FULL OUTER JOIN
> (select f1, f2 from table1 where f3 =2) b
> FULL OUTER JOIN
> (select f1, f2 from table1 where f3 =3) c
> on a.f1 = b.f1and a.f1 = c.f1
You need separate on clauses for each join:
select ...
from (
(select f1, f2 from table1 where f3=1) a
full outer join
(select f1, f2 from table1 where f3=2) b
on a.f1=b.f1)
full outer join
(select f1,f2 from table1 where f3=3) c
on a.f1=c.f1
should do it I think.
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2002-03-20 17:04 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-03-20 03:28 What is Syntax for multiple FULL OUTER JOINS? Patrick Hatcher <PHatcher@macys.com>
2002-03-20 04:08 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
2002-03-20 17:04 Re: What is Syntax for multiple FULL OUTER JOINS? Patrick Hatcher <PHatcher@macys.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox