Re: union and limit

From: "Nigel J(dot) Andrews" <nandrews(at)investsystems(dot)co(dot)uk>
To: Ben-Nes Michael <miki(at)canaan(dot)co(dot)il>
Cc: postgres <pgsql-general(at)postgresql(dot)org>
Subject: Re: union and limit
Date: 2002-08-27 09:52:58
Message-ID: Pine.LNX.4.21.0208271028280.667-100000@ponder.fairway2k.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 27 Aug 2002, Ben-Nes Michael wrote:

> Hi All
>
> i tried to send the following querry:
>
> select * from table limit 3,0 UNION ALL select * from table limit 3,0;
>
> This querry returned me an error so i put each select in parenthesis and it
> worked.
>
> Is this the way to solve it ?
> if it is, i think it should be in the docs.

If you read carefully the syntax for the SELECT from

http://developer.postgresql.org/docs/postgres/sql-select.html

you will see that the limit clause in the first select is not allowed
there. Don't forget the LIMIT applies to the entire result set not the last
select making up the union.

So in short, that is how it's supposed to work so there's no need to document
it.

--
Nigel J. Andrews
Director

---
Logictree Systems Limited
Computer Consultants

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Hegyvari Krisztian 2002-08-27 10:35:32 Re: union and limit
Previous Message Jules Alberts 2002-08-27 09:51:43 Re: how to count string occurrence in column