SQL SELECT TOP, LIMIT and ROWNUM Keywords
SELECT TOP, LIMIT and ROWNUM
The SELECT TOP
command is used to specify the number of records to return.
Note: Not all database systems support
SELECT TOP
. MySQL
uses LIMIT
, and Oracle uses
ROWNUM
.
The following SQL statement selects the first three records from the "Customers" table:
The following SQL statement shows the equivalent example using the LIMIT clause:
The following SQL statement shows the equivalent example using ROWNUM:
Example
SELECT * FROM Customers
WHERE ROWNUM <= 3;