Informix Limit Query - How to Limit Rows Returned in Query Results
Sometimes it is useful to limit the number of rows that are returned from a query. This can be especially useful when querying very large tables.
The Informix database provides the ability to limit the number of rows returned from a query starting at the beginning of the results using the first keyword, or returning a section of results from a query using the a combination of the first and skip syntax. Listed below are examples of limiting rows with the Informix database:
Example 1: Returning the first 50 rows from a table called employee:
SELECT FIRST 50 fname, lname FROM employee;
Example 2: Returning the first 50 rows starting at row 20 from a table called employee:
SELECT SKIP 20 FIRST 50 fname, lname FROM employee;
Many other databases also support limiting rows returned from queries. Listed below are links that show how to limit rows for other popular databases:
- Cassandra Limit Rows
- DB2 Limit Rows
- Derby Limit Rows
- Firebird Limit Rows
- H2 Limit Rows
- HSQLDB Limit Rows
- Microsoft SQL Server Limit Rows
- MySQL Limit Rows
- Oracle Limit Rows
- Pervasive Limit Rows
- PostgreSQL Limit Rows
- Redshift Limit Rows
- Salesforce Limit Rows
- SimpleDB Limit Rows
- SQLite Limit Rows
- Sybase Limit Rows
- Teradata Limit Rows