Languages
[Edit]
EN

MySQL - rows limit with offset

7 points
Created by:
maxsior322
347

In this short article, we would like to show how to get rows from table using LIMIT and OFFSET in MySQL query.

LIMIT and OFFSET should be placed always as last.

Quick solution:

Where: OFFSET is counted starting from 0 (it means to get first row from table we need to use OFFSET 0).

 

Short version

Edit

The same query can be written using shorter form:

Result:

  • 5 users (LIMIT is 5),
  • starting from 10th position (OFFSET is 10).

 

Complex example

Edit

 

1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
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