Home > Database > Mysql Tutorial > body text

分页,直接通过SQL取分页数据_MySQL

WBOY
Release: 2016-06-01 13:48:27
Original
832 people have browsed it

bitsCN.com

一个列表页面,之前程序员用了“Wuqi.Webdiyer”的分页插件,慢,且莫明出错。看了下代码,觉得冗余太多,故决定优化一下。

从网上找了些资料,考虑直接在SQL底层,直接只取当前页的数据,再绑定,这样效率应该会高些。

核心的SQL查询语句是这样的:

select top @size * from (@sqlstring) a where @key = (select min(@key) from (select top @end @key from (@sqlstring) a order by @key desc) a) order by @key desc
Copy after login
bitsCN.com
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!