MySQL Oracle Paging

Source: Internet
Author: User

(1) The limit m,n statement for MySQL

In the two parameters after limit, the parameter m is the starting subscript, which starts at 0 and the parameter n is the number of records returned. We need to specify these two values when paging.

For example: Query 10 rows of records, starting from 3.

SELECT * from EMP LIMIT 3, 10;

(2)rownum of Oracle database

the subquery is to be enclosed within parentheses.

Place the subquery on the right side of the comparison condition.

single-row operators correspond to single-line subqueries, and multiline operators correspond to multiple rows of subqueries.

subqueries can appear in the select,from,where,having clause

subqueries may not appear in the GROUP BY clause

the main query and subquery can use or not use a single representation

subqueries that follow the FROM clause are most important (for example, Oracle paging statements)

Select Yy.*
From (select RowNum ids,emp.* from emp where rownum<=9) yy
where ids>=5;

Example: If we want to sort the column Sal in the EMP table and then page it, we can write that.

SELECT *
From (select RowNum r,e1.*
From (SELECT * from emp ORDER by Sal) E1
where RowNum <=8
)
where R >=5;

MySQL Oracle Paging

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.