Re: union and limit

From: "Ben-Nes Michael" <miki(at)canaan(dot)co(dot)il>
To: "Nigel J(dot) Andrews" <nandrews(at)investsystems(dot)co(dot)uk>
Cc: "postgres" <pgsql-general(at)postgresql(dot)org>
Subject: Re: union and limit
Date: 2002-08-27 11:20:56
Message-ID: 004901c24dbb$cff41c20$aa0f5ac2@canaan.co.il
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.
>
Yes but, if i add parenthesis around each select, it is working.
But i wonder if its ok to use parenthesis around each select.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Wm. G. Urquhart 2002-08-27 11:35:43 Re: how to get the primary key of a freshly inserted row in a stored procedure
Previous Message Hegyvari Krisztian 2002-08-27 10:35:32 Re: union and limit