Re: Way to use count() and LIMIT? - Mailing list pgsql-general

From Mitch Vincent
Subject Re: Way to use count() and LIMIT?
Date
Msg-id 010401c18823$8c8abce0$0200000a@Mitch
Whole thread Raw
In response to Re: Way to use count() and LIMIT?  ("SHELTON,MICHAEL (Non-HP-Boise,ex1)" <michael_shelton@non.hp.com>)
Responses Re: Way to use count() and LIMIT?
List pgsql-general
see http://www.php.net/manual/en/function.pg-numrows.php

Still, this isn't what you want I'd say.. That just gives you the number of
rows returned by a query -- a query that uses LIMIT X return X or less
records, so that's not the most that pg_numrows() will ever give you is X...

I've run into this before when I did some search engine work with PG, it's a
pain but I've found no workaround... I ended up having to do two queries,
one a count() and one to return the records...

-Mitch


----- Original Message -----
From: "Doug McNaught" <doug@wireboard.com>
To: "SHELTON,MICHAEL (Non-HP-Boise,ex1)" <michael_shelton@non.hp.com>
Cc: <joe@jwebmedia.com>; <pgsql-general@postgresql.org>
Sent: Tuesday, December 18, 2001 4:49 PM
Subject: Re: [GENERAL] Way to use count() and LIMIT?


> "SHELTON,MICHAEL (Non-HP-Boise,ex1)" <michael_shelton@non.hp.com> writes:
>
> > Sorry I haven't been able to get back to you -- busy at work.
> >
> > One last comment to try is in MS SQL you can get the number of rows
returned
> > via @@ROW_COUNT -- however I couldn't find the equivalent for PG SQL
> > (doesn't mean there isn't one).
> >
> > Anyone else know what might work here?  The important detail is wanting
to
> > get a number of rows in the _result_ not necessarily the table.
>
> libpq gives you this information via the PQntuples() function.
> Whether PHP gives you access to that info I don't know--see your docs.
>
> -Doug
> --
> Let us cross over the river, and rest under the shade of the trees.
>    --T. J. Jackson, 1863
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Too Many Open Files... NetBSD
Next
From: Martijn van Oosterhout
Date:
Subject: Re: Way to use count() and LIMIT?