A
A
Alexander Tokmakov2014-11-03 00:15:58
PHP
Alexander Tokmakov, 2014-11-03 00:15:58

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

1 answer(s)
A
Anton Shamanov, 2014-11-03
@SilenceOfWinter

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 question

Ask a Question

731 491 924 answers to any question