MySQL efficient paging query procedure _ MySQL

Source: Internet
Author: User
The following articles mainly describe the actual operation steps of SQL Server, ORACLE, and MySQL efficient paging query. if the query results require paging, the related efficiency is generally described, the following efficiency should be relatively high (pink indicates the places to be filled according to the actual situation ). III. MySQL Query

The following articles mainly describe the actual operation steps of SQL Server, ORACLE, and MySQL efficient paging query. if the query results require paging, the related efficiency is generally described, the following efficiency should be relatively high (pink indicates the places to be filled according to the actual situation ).

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

Oracle (large website database platform ):

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

Write the actual SQL statement to be queried in parentheses

 
  1. ) AS MYTABLE WHERE ROWNUM <=200

This is the last record on the page.

 
  1. \) WHERE MY_ROWNUM>=10

This is the first record on the page.

 
  1. SQLServer: SELECT * FROM (

SQLSERVER, ORACLE, and MySQL efficient paging query: select top page capacity * FROM (

Select top Page capacity * Current page number * FROM

Table WHERE condition order by field A ASC

 
  1. ) AS TEMPTABLE1 order by field A DESC
  2. ) AS TEMPTABLE2 order by field A ASC

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

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

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.