点击

分页

分页

​ MySQL 使用limit 实现数据的分页显示

格式:
limit [位置偏移量],行数;

每页显示20条记录

​ select employee_id,last_name from employees limit 0,20;

image-20221113114151485

声明格式如下:

​ where …… order by …… limit

select employee_id,last_name, salary from employees where salary >6000 order by salary desc limit 0,10;

limit的格式:limit 位置,条目数

​ 结构 :"limit 0,条目数" 等价于 "limit 条目数"

select employee_id,last_name, salary from employees where salary >6000 order by salary desc limit 10;

​ 只有偏移量为0才能这样写

mysql8.0

select employee_id,last_name,salary from employees limit 2 offset 31;

mysql8.0limit后是 条目数 ,offset 后是 偏移量。

练习

​ 查询员工表中工资最高的员工

select employee_id,salary from employees order by salary Desc limit 0,1;

posted @ 2023-01-23 15:01  RILI520  阅读(27)  评论(0)    收藏  举报