Getting a total hit number and a LIMIT number at the same time - Mailing list pgsql-general

From
Subject Getting a total hit number and a LIMIT number at the same time
Date
Msg-id 371EAC487A83CD4296F6999FD088D8331B7084@atlas.managestar.com
Whole thread Raw
List pgsql-general
I have a table with 5,000 rows in it. I also have a query that returns
about 950 rows, but I only want items 50-60 from that match.
    What I want to show the user is
      - the total # of matches (950)
      - the 10 rows that I want

The following works, but can it be reduced to a single query?

    SELECT COUNT(*) FROM ... WHERE ...
    (print out the total number of matches)

    SELECT * FROM ... WHERE ... OFFSET 50 LIMIT 10
    (print out the 10 rows)

pg_cmdtuples($result) shows the number of *affected* tuples.

Thanks, Jeff

pgsql-general by date:

Previous
From: Gilles DAROLD
Date:
Subject: Oracle to Pg tool
Next
From: Janning Vygen
Date:
Subject: updating rows while selecting