Re: Select count with offset returns nothing.

From: Misa Simic <misa(dot)simic(at)gmail(dot)com>
To: pgsql <pgsql-general(at)postgresql(dot)org>
Subject: Re: Select count with offset returns nothing.
Date: 2011-08-05 11:01:28
Message-ID: CAH3i69kR51A-y7Jadnv9wEQNRYrm0L+cDy386W9zS19Vz3w1Kg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I think problem is in OFFSET 15

It means return rows after row 15... because of SELECT COUNT(*)
FROM batches LIMIT 15 returns 1 row when you add OFFSET 15 - it returns
nothing... because of there is no more than 15 rows...

I am not sure u can do something else then to change library to remove
OFFSET in SELECT COUNT(*)

Kind Regrads,

Misa
2011/8/5 Tim Uckun <timuckun(at)gmail(dot)com>

> I am using a library which is emitting SQL like this SELECT COUNT(*)
> FROM batches LIMIT 15 OFFSET 15 the library fails because on postgres
> this query returns nothing (not even zero as a result). Presumably it
> returns some valid value on mysql and other databases.
>
> Other than hacking the library is there anything I can do?
>
> Oddly enough SELECT count(*) FROM batches LIMIT 15 returns the full
> count of the table. Presumably the count has to be done on a subquery
> right?
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jerry Sievers 2011-08-05 11:20:01 Re: Postgresql problem with update double precision
Previous Message Daniel Winterstein 2011-08-05 10:58:54 Can GiST for tsvector be optimised? #TextSearch