SELECT TOP, LIMIT and ROWNUM
The LIMIT, SELECT TOP or ROWNUM command is used to specify the number of records to return.
Note: SQL Server uses
SELECT TOP. MySQL usesLIMIT, and Oracle usesROWNUM.
The following SQL statement selects the first three records from the "Customers" table (SQL SERVER):
Example
sql
SELECT TOP 3 * FROM Customers;
The following SQL statement shows the equivalent example using the LIMIT clause (MySQL):
Example
sql
SELECT * FROM Customers
LIMIT 3;
The following SQL statement shows the equivalent example using ROWNUM (Oracle):
Example
sql
SELECT * FROM Customers
WHERE ROWNUM <= 3;