mysql 查询语句
分页语句
常用方式 limit
SELECT * FROM table ORDER BY id asc LIMIT 1000, 10;
优化方式 一
SELECT * FROM table WHERE id >= (SELECT id FROM table LIMIT 1000, 1) LIMIT 10;
优化方式二
SELECT * FROM table WHERE id BETWEEN 0 AND 1000;
优化方式三(先找出id)
SELECT * FROM table WHERE id IN(1000, 1001, 1002...);
优化方式四(其实是对方式二的优化)解决id不连续问题,但是有个问题就是不能加其他查询条件
SELECT * FROM table WHERE id BETWEEN (SELECT id FROM table LIMIT 0,1) AND(SELECT id FROM table LIMIT 1000,1);
(转载请注明花儿为何那样红博客)