Paging, directly retrieve paging data through SQL _ MySQL-mysql tutorial

Source: Internet
Author: User
Paging: retrieves paging data using SQL directly bitsCN.com

On a list page, the programmer used the "Wuqi. Webdiyer" paging plug-in, which is slow and has an error. After reading the code, I thought there was too much redundancy, so I decided to optimize it.

After looking for some information from the Internet, consider directly at the bottom of the SQL, directly retrieve the data on the current page, and then bind it, which should be more efficient.

The core SQL query statement is as follows:

Select top @ size * from (@ sqlstring) a where @ key <= (select min (@ key) from (select top @ star @ key from (@ sqlstring) a order by @ key desc) a) and @ key >=( select min (@ key) from (select top @ end @ key from (@ sqlstring) a order by @ key desc) a) order by @ key desc
BitsCN.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.