The LIMIT, SELECT TOP, or ROWNUM command is employed to determine the number of records to be returned.
Note: SQL Server employs SELECT TOP, MySQL utilizes LIMIT, and Oracle uses ROWNUM. |
The subsequent SQL statement retrieves the first three records from the “Customers” table (for SQL Server):
SELECT TOP 3 * FROM Customers; |
The following SQL statement illustrates an equivalent example using the LIMIT clause (for MySQL):
SELECT * FROM Customers LIMIT 3; |
The following SQL statement demonstrates an equivalent example using ROWNUM (for Oracle):
SELECT * FROM Customers WHERE ROWNUM <= 3; |