深度分页,我都是这么玩的
猿天地
共 2132字,需浏览 5分钟
·
2022-02-17 20:31
点击上方蓝字“设为星标”
select * from table where id < #{lastId} order by id desc limit #{limit}
4 2022-01-01 12:12:12.111431
3 2022-01-01 12:12:12.111431
2 2022-01-01 12:12:10.111431
1 2022-01-01 12:12:09.111431
我们的SQL如下:
select * from table order by time desc limit 1
select * from table where time < '2022-01-01 12:12:12.111431' order by time desc limit 1
select * from table where time < '2022-01-01 12:12:12.111431' or (time='2022-01-01 12:12:12.111431' and id < 4) order by time desc,id desc limit 1
大家好,我是从古代穿越过来的美男子:架构摆渡人。我将把我的武功秘籍全部传授与你们,觉得有用请分享给身边的朋友。来个三连吧,感谢各位!另外我还在B站录制了《真实订单业务,亿级数据带你实战分库分表》的实战课程,记得去学习哦!
评论