Sql to select the top 10 records

I have the following table (dots):

    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 need to show only a dozen entries with dots (desc) and five entries on each page. I execute the SQL statement:

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

thank

+3
source share
2 answers

for the first page:

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

for the second page:

SELECT * FROM points p ORDER BY points DESC LIMIT 5, 5
+5
source

You cannot execute an SQL query to return a given number of pages, you will have to implement some kind of pagination module or some equivalent for the script you are in and get LIMIT 0, 5for one, then LIMIT 5, 5for the other.

, , . - .

0

Source: https://habr.com/ru/post/1735780/


All Articles