Answer the question
In order to leave comments, you need to log in
How to write a correct sql query?
the table table has an unlimited number of records.
SELECT id FROM table ORDER BY id
outputs: 1,2,3,4,5,6,7,8,9,10
SELECT id FROM table ORDER BY id DESC LIMIT 5
outputs: 10,9,8,7,6
SELECT id FROM table ORDER BY id ASC LIMIT 5
outputs: 1,2,3,4,5
QUESTION: How to write a query to display: 6,7,8,9,10
That is, the last 5 id in ascending order
DBMS: mysqli,pdo .mysql
Answer the question
In order to leave comments, you need to log in
Depends on the DBMS, if the number of records is limited, thenWHERE IN (6,7,8,9,10)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question