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

TOP

SELECT TOP, LIMIT and ROWNUM

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):

Example

SELECT TOP 3 * FROM Customers;

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

Example

SELECT * FROM Customers
LIMIT 3

The following SQL statement demonstrates an equivalent example using ROWNUM (for Oracle):

Example

SELECT * FROM Customers
WHERE ROWNUM <= 3;