|
The LIMIT clause allows you to limit the number of rows returned by the query.
The LIMIT clause is an extension of the SELECT statement that has the following syntax:
A cláusula LIMIT permite limitar o número de linhas retornadas pela consulta.
A cláusula LIMIT é uma extensão da instrução SELECT que possui a seguinte sintaxe:
SELECT select_list
FROM table_name
ORDER BY sort_expression
LIMIT n [OFFSET m];
|
In this syntax: - Nesta sintaxe:
- n is the number of rows to be returned. - n é o número de linhas a serem retornadas.
- m is the number of rows to skip before returning the n rows. - m é o número de linhas a pular antes de retornar as n linhas.
Another shorter version of LIMIT clause is as follows:
Outra versão mais curta da cláusula LIMIT é a seguinte:
SELECT select_list
FROM table_name
ORDER BY sort_expression
LIMIT m , n;
|
This syntax means skipping m rows and returning the next n rows from the result set.
A table may store rows in an unspecified order.
If you don’t use the ORDER BY clause with the LIMIT clause, the returned rows are also unspecified.
Therefore, it is a good practice to always use the ORDER BY clause with the LIMIT clause.
Esta sintaxe significa pular m linhas e retornar as próximas n linhas do conjunto de resultados.
Uma tabela pode armazenar linhas em uma ordem não especificada.
Se você não usar a cláusula ORDER BY com a cláusula LIMIT, as linhas retornadas também não serão especificadas.
Portanto, é uma boa prática sempre usar a cláusula ORDER BY com a cláusula LIMIT.
The following SQL statement selects the first three records from the "Customers" table:
A seguinte instrução SQL seleciona os três primeiros registros da tabela "Clientes":
SELECT TOP 3 *
FROM Customers;
|
The following SQL statement shows the equivalent example using the LIMIT clause:
A seguinte instrução SQL mostra o exemplo equivalente usando a cláusula LIMIT:
SELECT *
FROM Customers
LIMIT 3;
|
The following SQL statement shows the equivalent example using ROWNUM:
A seguinte instrução SQL mostra o exemplo equivalente usando ROWNUM:
SELECT *
FROM Customers
WHERE ROWNUM <= 3; |
|