Re: UNION not working... why?

From: Richard Huxton <dev(at)archonet(dot)com>
To: Stefan Schwarzer <stefan(dot)schwarzer(at)grid(dot)unep(dot)ch>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: UNION not working... why?
Date: 2007-12-13 16:49:19
Message-ID: 4761628F.4070002@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Stefan Schwarzer wrote:
> Hi there,
>
> I have two rather simple queries, which I would to UNION, but somehow I
> always get an error message for the UNION ("ERROR: syntax error at or
> near "UNION"")

> SELECT
> ORDER BY
> LIMIT 1
>
> UNION ALL
...

I think it's complaining about the order by/limit. The UNION is part of
the standard SELECT grammar and has its own ORDER BY (if you see what
I'm getting at).

Try SELECT * FROM (SELECT ... ORDER BY) AS foo UNION ...

--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Stehule 2007-12-13 16:53:48 Re: UNION not working... why?
Previous Message Kris Jurka 2007-12-13 16:49:18 Re: Synthesize support for Statement.getGeneratedKeys()?