Getting a total hit number and a LIMIT number at the same time

Поиск
Список
Период
Сортировка
От
Тема Getting a total hit number and a LIMIT number at the same time
Дата
Msg-id 371EAC487A83CD4296F6999FD088D8331B7084@atlas.managestar.com
обсуждение исходный текст
Список 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 по дате отправления:

Предыдущее
От: Gilles DAROLD
Дата:
Сообщение: Oracle to Pg tool
Следующее
От: Janning Vygen
Дата:
Сообщение: updating rows while selecting