小编典典

sql选择前10条记录

sql

我有下表(要点):

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

我需要的是仅显示按点(desc)排列的前十条记录,以及每页上的五条记录。我有以下SQL语句:

    select * from points where uid in(a,c) order by uid LIMIT 1, 5

谢谢


阅读 263

收藏
2021-04-14

共1个答案

小编典典

第一页:

SELECT * FROM points p ORDER BY points DESC LIMIT 0, 5

对于第二页:

SELECT * FROM points p ORDER BY points DESC LIMIT 5, 5
2021-04-14