SQL查询语句中的 limit 与 offset 的区别:
limit y分句表示: 读取 y 条数据limit x, y分句表示: 跳过 x 条数据,读取 y 条数据limit y offset x分句表示: 跳过 x 条数据,读取 y 条数据
比如分页获取数据:
第1页: 跳过0条数据,获取20条数据 (即1~20条)
select * from testtable limit 0, 20; select * from testtable limit 20 offset 0;
第2页: 跳过20条数据,获取20条数据 (即21~40条)
select * from testtable limit 20, 20; select * from testtable limit 20 offset 20;
第3页: 跳过40条数据,获取20条数据 (即41~60条)
select * from testtable limit 40, 20; select * from testtable limit 20 offset 40;
[END]
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/209895.html原文链接:https://javaforall.net
