Demo of the MySQL efficient paging query procedure

Source: Internet
Author: User

This article mainly describes the actual operation procedures of SQL Server, ORACLE, and MySQL efficient paging query, as well as the statements and codes we need to use in actual operations, the following is a description of the specific solution. I hope it will help you in your future study.

If the query results need to be paged, the efficiency below should be relatively high (pink indicates the location to be filled according to the actual situation)

Efficient paging query methods in three types of databases (currently ):

Oracle (large website database platform): SELECT * FROM (

 
 
  1. SELECT MY_TABLE.*,ROWNUM AS MY_ROWNUM FROM (  

/** Write the actual SQL statement to be queried in parentheses **/

) As mytable where rownum <= 200/** this is the last record on the page **/

\) WHERE MY_ROWNUM> = 10/** here is the first record on the page **/

 
 
  1. SQLServer: SELECT * FROM ( 

Select top page capacity * FROM (

Select top page capacity * Current page number * FROM

Table WHERE condition order by field A ASC

) AS TEMPTABLE1 order by field A DESC

) AS TEMPTABLE2 order by field A ASC

MySQL (best combination with PHP): the first record on the SELECT statement LIMIT page-1, page capacity

The above content is an introduction to SQL Server, ORACLE, and MySQL efficient paging query. I hope you will find some gains.


The above content describes the efficient paging query of SQLSERVER, ORACLE, and MySQL. I hope it will help you in this regard.

Related Article

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.