S
S
sergeev_ev2018-06-08 15:15:06
MySQL
sergeev_ev, 2018-06-08 15:15:06

How does mysql limit work?

Good afternoon!
Colleagues, please explain why my query with LIMIT
works like in the example from this article:
https://ruhighload.com/post/Mysql+LIMIT
The block is described under the Offset heading.
SELECT * FROM users ORDER BY id DESC LIMIT 5, 10
and not like this: 2sql.ru/advanced/sql-limit
SELECT
UniversityName FROM Universities LIMIT 4, 6 I have a pattern break. Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2018-06-08
@sergeev_ev

Because the correct description of the limit syntax is given in the first article.
What is checked by the original source https://dev.mysql.com/doc/refman/8.0/en/select.html
A selection is formed from row_count + offset of the number of rows, then the first offset rows are discarded and no more than row_count rows get into the result set.
Without an explicitly specified order by, the selection does not make sense at all, the DBMS, according to the standard, has the right to return any data that satisfies the request in any order at its discretion. Accordingly, offset will be taken from nowhere and it is not clear how.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question