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

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

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.***.com/



Mon, 27 Oct 2003 01:18:01 GMT
 
 [ 1 post ] 

 Relevant Pages 

1. Oracle Newbie : Getting only limited number of rows

2. Getting limited number of rows on a table

3. Oracle Newbie : Getting only limited number of rows

4. Getting limited number of rows on a table

5. Limiting the number of records processed at a time

6. NUMBER(9) UNION NUMBER(9) results in NUMBER(32,32)

7. How to determine the number of hits to an Index

8. Maximum number of simultaneous hits for Oracle 8.0

9. Help - I've hit the maximum number of extents in Informix 5

10. "Hit list" numbering

11. REPOST: How to determine the number of hits to an Index


 
Powered by phpBB® Forum Software