记录在一百万(最好是在八十万)以内时,可以参照上一贴http://topic.csdn.net/u/20100201/16/dc9ad7d7-840b-4ded-9d7a-d94db5bc235f.html。如果超过了这个数据,最好只以主键为条件进行分页取总数: Select SQL_BUFFER_RESULT count(id) as all_ID from my_tab
总页数: 总数/每页条数
最后一页的条数: 总数%每页条数查询数据:
select id,title,price from my_tab m INNER JOIN ( select id as my_id from ( select id from my_tab order by id desc limit 100,100 ) as tmp ) as temp ON my_id=id第一步、按照最快原则,以主键id作为条件排序 ( select id from my_tab order by id desc limit 100,100 ) as tmp第二步、按照最少原则,只取回当前所需的记录,而且只取id ( select id from my_tab order by id desc limit 100,100 ) as tmp第三步、按照最快原则,以主键id作为条件取回所需的信息 select id,title,price from my_tab m INNER JOIN ( ... ) as temp ON my_id=id显示效果请看实例:http://58.ebweek.com
有不足之处请大家拍砖!

解决方案 »

  1.   

    如果数据量这么大,还有一种方法,是通过估算来得到起始ID xx,然后 where id>xx limit 100
      

  2.   

    分页没有什么什么好方法,一般用TOP、LIMIT之类的,再与工作表连接 
      

  3.   


    同意,根據分頁,下一頁,id>xx,上一頁 ,id<xx   limit 100
      

  4.   

    我记得我以前在公司写过一个SP,是不停的循环ID,然后得到分页的数据。效率非常高。