javaEEday07-DQL-Select-分页查询
This commit is contained in:
+27
-1
@@ -146,4 +146,30 @@ select * from tb_emp order by entrydate asc,id desc;
|
||||
select * from tb_emp where name like '%张%'
|
||||
and gender = 1
|
||||
and entrydate between '2000-01-01' and '2010-01-01'
|
||||
order by update_time asc;
|
||||
order by update_time asc;
|
||||
|
||||
|
||||
|
||||
-- =================== 分页查询 ======================
|
||||
-- 1. 查询第1页员工数据, 每页展示10条记录
|
||||
select * from tb_emp limit 10; -- 如果是0索引开始取,是可以省略,建议别省略
|
||||
|
||||
select * from tb_emp limit 0,10;
|
||||
|
||||
-- 2. 查询第2页员工数据, 每页展示10条记录
|
||||
select * from tb_emp limit 10,10;
|
||||
|
||||
-- 3. 查询第3页员工数据, 每页展示10条记录
|
||||
select * from tb_emp limit 20,10;
|
||||
|
||||
-- 分页的公式:页码(page)和每页显示的数量(pageNum)----->起始索引 = (页码 - 1)*每页显示的数量
|
||||
|
||||
-- 练习 : 员工管理列表查询 , 根据最后操作时间, 进行倒序排序 进行分页显示,一页显示5条,显示第二页的数据
|
||||
-- 条件 : name , gender , entrydate
|
||||
|
||||
select * from tb_emp
|
||||
where name like '%张%'
|
||||
and gender = 1
|
||||
and entrydate between '2000-01-01' and '2020-01-01'
|
||||
order by update_time desc
|
||||
limit 5,5;
|
||||
Reference in New Issue
Block a user