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;
Informix:
SELECT FIRST 10 * FROM table;
Microsoft SQL Server and Access:
SELECT TOP 10 * FROM table;
Oracle:
SELECT * FROM (SELECT * FROM table) WHERE rownum <= 10;
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!