Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
Text lesson

LIMIT

SELECT TOP, LIMIT and ROWNUM

The LIMIT, SELECT TOP, or ROWNUM command is employed to specify the number of records to be returned.

Please note that 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):

Example

SELECT TOP 3 * FROM Customers;

The following SQL statement demonstrates the equivalent example using the LIMIT clause (for MySQL):

Example

SELECT * FROM Customers
LIMIT 3

The following SQL statement illustrates the equivalent example using ROWNUM (for Oracle):

Example

SELECT * FROM Customers
WHERE ROWNUM <= 3;