Languages
[Edit]
EN

MySQL limit with offset

4 points
Created by:
maxsior322
227

Quick solution:

SELECT * FROM users ORDER BY id ASC LIMIT 2 OFFSET 5;

OFFSET starts from 0. 

To get first record from database we need to use OFFSET 0.

Result will be 2 users (as our LIMIT is 2) and query starts the select from offset.

The same query shorter:

SELECT * FROM posts ORDER BY id ASC LIMIT 2, 5;

 

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join