bugl
bugl
HomeLearnPatternsSearch
HomeLearnPatternsSearch

Loading lesson path

Learn/SQL/SQL References
SQL•SQL References

SQL SELECT TOP, LIMIT and ROWNUM Keywords

Concept visual

SQL SELECT TOP, LIMIT and ROWNUM Keywords

Pointer walk
two pointers
leftright102132436485116
left=0
right=6
1
3

Start at both ends

SELECT TOP, LIMIT and ROWNUM Keywords

Previous

❮ SQL Keywords

Next

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

uses LIMIT, and Oracle uses ROWNUM. The following SQL statement selects the first three records from the "Customers" table (SQL SERVER):

Example

SELECT TOP 3 * FROM Customers;

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

Example

SELECT * FROM Customers
LIMIT 3;

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

Example

SELECT * FROM Customers
WHERE ROWNUM  <= 3;

Previous

❮ SQL Keywords

Next

Previous

SQL RIGHT JOIN Keyword

Next

SQL SELECT Keyword