MySql database query (DQL) language - paging query

Paging query

First, the scenario
data when you want to display, a display failure, need to submit sql paging request.

Two, sql grammar

select 查询列表 from 表
......
limit offset, size;

offset: To display the starting index entry (starting index from 0);
size: the number of entries to be displayed.

Third, the use case

  1. Query before five employee information.
    select * from employees limit 0, 5;
    or
    select * from employees limit 5;

  2. Queries Article 25 Article 11 employee information.
    select * from employees limit 10, 15;

Fourth, the use of features

  1. limit general statements on the final sql statements;
  2. The application layer paging query formula
    page: Indicates the number of pages to be displayed, that is, the first few pages;
    size: represents the number of each page to be displayed;
    select * from table limit (page - 1) * size, size;

Guess you like

Origin blog.csdn.net/u010982507/article/details/90735337
Recommended