Oracle 5.0 Reference Manual page 1106

Table of Contents

Advertisement

SELECT * FROM tbl LIMIT 5,10;
To retrieve all rows from a certain offset up to the end of the result set, you can use some large
number for the second parameter. This statement retrieves all rows from the 96th row to the last:
SELECT * FROM tbl LIMIT 95,18446744073709551615;
With one argument, the value specifies the number of rows to return from the beginning of the result
set:
SELECT * FROM tbl LIMIT 5;
In other words,
LIMIT row_count
For prepared statements, you can use placeholders (supported as of MySQL version 5.0.7). The
following statements will return one row from the
SET @a=1;
PREPARE STMT FROM 'SELECT * FROM tbl LIMIT ?';
EXECUTE STMT USING @a;
The following statements will return the second to sixth row from the
SET @skip=1; SET @numrows=5;
PREPARE STMT FROM 'SELECT * FROM tbl LIMIT ?, ?';
EXECUTE STMT USING @skip, @numrows;
For compatibility with PostgreSQL, MySQL also supports the
syntax.
If
occurs within a subquery and also is applied in the outer query, the outermost
LIMIT
precedence. For example, the following statement produces two rows, not one:
(SELECT ... LIMIT 1) LIMIT 2;
• A
clause names a procedure that should process the data in the result set. For an
PROCEDURE
example, see
Section 8.8.2, "Using
that can be used to obtain suggestions for optimal column data types that may help reduce table
sizes.
• The
SELECT ... INTO
variables. For more information, see
If you use
FOR UPDATE
query are write-locked until the end of the current transaction. Using
a shared lock that permits other transactions to read the examined rows but not to update or delete
them. See
Section 14.2.7.3,
Locking
Reads".
MODE
Following the
SELECT
statement. HIGH_PRIORITY, STRAIGHT_JOIN, and options beginning with
extensions to standard SQL.
The
and
ALL
DISTINCT
default) specifies that all matching rows should be returned, including duplicates.
specifies removal of duplicate rows from the result set. It is an error to specify both options.
is a synonym for DISTINCT.
DISTINCTROW
gives the
HIGH_PRIORITY
You should use this only for queries that are very fast and must be done at once. A
query that is issued while the table is locked for reading runs even if there is an
HIGH_PRIORITY
update statement waiting for the table to be free. This affects only storage engines that use only
table-level locking (such as MyISAM, MEMORY, and MERGE).
SELECT
# Retrieve rows 6-15
# Retrieve first 5 rows
is equivalent to
PROCEDURE
form of
enables the query result to be written to a file or stored in
SELECT
Section 13.2.8.1,
with a storage engine that uses page or row locks, rows examined by the
"SELECT ... FOR UPDATE
keyword, you can use a number of options that affect the operation of the
options specify whether duplicate rows should be returned.
higher priority than a statement that updates a table.
SELECT
1086
Syntax
LIMIT 0,
row_count.
table:
tbl
LIMIT row_count OFFSET offset
ANALYSE", which describes ANALYSE, a procedure
"SELECT ... INTO
and
SELECT ... LOCK IN SHARE
table:
tbl
LIMIT
Syntax".
LOCK IN SHARE MODE
are MySQL
SQL_
ALL
DISTINCT
SELECT
takes
sets
(the

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents