Back to Mysql database theory and practice # advanced 9: pagination query ★

Introduction: In practical development, a page is not always displayed with all data, so the paging query syntax is used: Select table ⑥ from table ① 【join table ② on join condition ③ WHERE filter ④ group by group ⑤ having filter ⑦ order by sort ⑧】 limit [Start item number,] The number of items to query; Pet-name ruby

Features: The initial number of entries can be omitted, starting with 1 by default. Note: the starting index starts at 0

Size select * from employees limit (page-1)*size,size;

Size =10 page=1 limit 0,10 page=2 limit 10,10 page=3 limit 20,10.... SELECT * FROM employees LIMIT 0,5; SELECT * FROM employees LIMIT 5; SELECT * FROM employees LIMIT 10,10; # Case 3: SELECT last_name,salary,commission_pct,department_id FROM employees WHERE commission_pct IS  NOT NULL ORDER BY salary DESC LIMIT 3;Copy the code