Home > Database > Mysql Tutorial > How to Limit Rows in ANSI SQL and Different RDBMS?

How to Limit Rows in ANSI SQL and Different RDBMS?

Linda Hamilton
Release: 2024-11-28 21:18:15
Original
880 people have browsed it

How to Limit Rows in ANSI SQL and Different RDBMS?

Limiting Rows in ANSI SQL

The MYSQL LIMIT keyword is a convenient way to limit the number of rows returned from a query. However, it is not a standard ANSI SQL syntax. For other RDBMS, there are several alternative ways to achieve row limiting.

DB2:

SELECT * FROM table FETCH FIRST 10 ROWS ONLY;
Copy after login

Informix:

SELECT FIRST 10 * FROM table;
Copy after login

Microsoft SQL Server and Access:

SELECT TOP 10 * FROM table;
Copy after login

Oracle:

SELECT * FROM (SELECT * FROM table) WHERE rownum <= 10;
Copy after login

Conclusion:

Although the MYSQL LIMIT keyword is not an ANSI SQL standard, there are various alternative ways to limit rows in different database systems. The specific syntax may vary depending on the RDBMS being used.

The above is the detailed content of How to Limit Rows in ANSI SQL and Different RDBMS?. For more information, please follow other related articles on the PHP Chinese website!

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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template