首页 > 代码库 > My Sql 高效分页

My Sql 高效分页

/*
 *普通分页
 *在数据文件上偏移1000000查出10条
 */

select *
from zoldesk_92game_net_ecms_bj
where classid=303
ORDER BY id ASC
LIMIT 1000000,10

/*
 *高效分页
 *1、在索引上查出起始索引
 *2、从起始索引上查出10条
 */

SELECT * from zoldesk_92game_net_ecms_bj WHERE id >=
(
    SELECT id
    FROM zoldesk_92game_net_ecms_bj
    where classid=303
    ORDER BY id ASC
    LIMIT 1000000, 1
)
where classid=303
ORDER BY id ASC
LIMIT 10