tags:

views:

84

answers:

2

i have following database table name tbl_rec

             recno   uid   uname   points
             ============================
              1       a     abc      10
              2       b     bac      8
              3       c     cvb      12
              4       d     aty      13
              5       f     cyu      9
              -------------------------
              -------------------------

i have about 5000 records in this table.

i want to select first 50 higher points records.

i can't use limit statement as i am already using limit for paging.

Thanks

+4  A: 

i want to select first 50 higher points records.

Then:

  SELECT tr.*
    FROM TBL_REC tr
ORDER BY tr.points DESC
   LIMIT 50

i can't use limit statement as i am already using limit for paging.

Then use a subquery:

SELECT x.*
  FROM (SELECT tr.*
          FROM TBL_REC tr
      ORDER BY tr.points DESC
         LIMIT 50) x
 LIMIT a, b --for your pagation
OMG Ponies
Think of this question a little more :)
Col. Shrapnel
+1  A: 

I am stupid. Didnt get it right at first.
Pagination itself is displaying top XX!

Want it pagitnated? All right, order table as you wish and make limit whatever you want. Then paginate until it reach 50, then stop.

Col. Shrapnel