Re: JOINing subselects in FROM?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)atentus(dot)com>
Cc: PgSQL general <pgsql-general(at)postgresql(dot)org>
Subject: Re: JOINing subselects in FROM?
Date: 2002-04-10 15:02:08
Message-ID: 5280.1018450928@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Alvaro Herrera <alvherre(at)atentus(dot)com> writes:
> I'm trying to JOIN two subselects-in-from clauses and can't get it
> right:

> SELECT foo1.mes, valor1999 AS "1999", valor2000 AS "2000" FROM
> (SELECT valor AS valor1999, mes FROM datos WHERE ao=1999) AS foo1
> OUTER JOIN
> (SELECT valor AS valor2000, mes FROM datos WHERE ao=2000) AS foo2
> ON foo1.mes=foo2.mes;
> ERROR: parser: parse error at or near "OUTER"

Should be LEFT JOIN or LEFT OUTER JOIN.

> If I try to do an INNER JOIN, I get instead
> SELECT foo1.mes, valor1999 AS "1999", valor2000 AS "2000" FROM
> (SELECT valor AS valor1999, mes FROM datos WHERE ao=1999) AS foo1
> INNER JOIN
> (SELECT valor AS valor2000, mes FROM datos WHERE ao=2000) AS foo2
> ON foo1.mes=foo2.mes;
> ERROR: flatten_join_alias_var: unexpected subtree type

[ scratches head ... ] I do not get that. I think there must be
something broken about your build; or perhaps there's a portability
problem lurking in devel sources. Would you try a full rebuild (make
distclean, configure, build, initdb) to eliminate the possibility of
internal version mismatches?

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Joe Conway 2002-04-10 15:14:21 Re: Postgresql 7.2
Previous Message Lincoln Yeoh 2002-04-10 14:33:51 Re: vacuuming not working?