DO
Syntax
1064
WHERE a1.id=a2.id;
13.2.3.
DO
Syntax
DO
expr
[,
expr
] ...
DO
executes the expressions but does not return any results. In most respects,
DO
is shorthand for
SELECT expr, ...
, but has the advantage that it is slightly faster when you do not care about the
result.
DO
is useful primarily with functions that have side effects, such as
RELEASE_LOCK()
[967]
.
13.2.4.
HANDLER
Syntax
HANDLER
tbl_name
OPEN [ [AS]
alias
]
HANDLER
tbl_name
READ
index_name
{ = | <= | >= | < | > } (
value1
,
value2
,...)
[ WHERE
where_condition
] [LIMIT ... ]
HANDLER
tbl_name
READ
index_name
{ FIRST | NEXT | PREV | LAST }
[ WHERE
where_condition
] [LIMIT ... ]
HANDLER
tbl_name
READ { FIRST | NEXT }
[ WHERE
where_condition
] [LIMIT ... ]
HANDLER
tbl_name
CLOSE
The
HANDLER
statement provides direct access to table storage engine interfaces. It is available for
MyISAM
and
InnoDB
tables.
The
HANDLER ... OPEN
statement opens a table, making it accessible using subsequent
HANDLER ... READ
statements. This table object is not shared by other sessions and is not closed
until the session calls
HANDLER ... CLOSE
or the session terminates. If you open the table using an
alias, further references to the open table with other
HANDLER
statements must use the alias rather
than the table name.
The first
HANDLER ... READ
syntax fetches a row where the index specified satisfies the given
values and the
WHERE
condition is met. If you have a multiple-column index, specify the index column
values as a comma-separated list. Either specify values for all the columns in the index, or specify
values for a leftmost prefix of the index columns. Suppose that an index
my_idx
includes three
columns named
col_a
,
col_b
, and
col_c
, in that order. The
HANDLER
statement can specify values
for all three columns in the index, or for the columns in a leftmost prefix. For example:
HANDLER ... READ my_idx = (col_a_val,col_b_val,col_c_val) ...
HANDLER ... READ my_idx = (col_a_val,col_b_val) ...
HANDLER ... READ my_idx = (col_a_val) ...
To employ the
HANDLER
interface to refer to a table's
PRIMARY KEY
, use the quoted identifier
`PRIMARY`
:
HANDLER
tbl_name
READ `PRIMARY` ...
The second
HANDLER ... READ
syntax fetches a row from the table in index order that matches the
WHERE
condition.
The third
HANDLER ... READ
syntax fetches a row from the table in natural row order that matches
the
WHERE
condition. It is faster than
HANDLER tbl_name READ index_name
when a full table scan
is desired. Natural row order is the order in which rows are stored in a
MyISAM
table data file. This
statement works for
InnoDB
tables as well, but there is no such concept because there is no separate
data file.
Without a
LIMIT
clause, all forms of
HANDLER ... READ
fetch a single row if one is available. To
return a specific number of rows, include a
LIMIT
clause. It has the same syntax as for the
SELECT
statement. See
Section 13.2.8, “
SELECT
Syntax”
.
HANDLER ... CLOSE
closes a table that was opened with
HANDLER ... OPEN
.
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...