Oracle 5.0 Reference Manual page 980

Table of Contents

Advertisement

characteristic. In the latter case,
INVOKER
This applies to stored programs as of MySQL 5.0.10 and to views as of MySQL 5.0.24. (For older
versions,
CURRENT_USER()
Triggers and events have no option to define the
[959]
CURRENT_USER()
invoker, use
USER()
[960]
DATABASE()
Returns the default (current) database name as a string in the
default database,
DATABASE()
the database that the routine is associated with, which is not necessarily the same as the database
that is the default in the calling context.
mysql>
SELECT DATABASE();
-> 'test'
[960]
FOUND_ROWS()
A
statement may include a
SELECT
the client. In some cases, it is desirable to know how many rows the statement would have returned
without the LIMIT, but without running the statement again. To obtain this row count, include a
SQL_CALC_FOUND_ROWS
afterward:
mysql>
SELECT SQL_CALC_FOUND_ROWS * FROM tbl_name
->
WHERE id > 100 LIMIT 10;
mysql>
SELECT FOUND_ROWS();
The second
SELECT
returned had it been written without the
In the absence of the
statement,
FOUND_ROWS()
statement. If the statement includes a
of rows up to the limit. For example,
statement includes
LIMIT 10
The row count available through
past the statement following the
the value later, save it:
mysql>
SELECT SQL_CALC_FOUND_ROWS * FROM ... ;
mysql>
SET @rows = FOUND_ROWS();
If you are using
SELECT
the full result set. However, this is faster than running the query again without LIMIT, because the
result set need not be sent to the client.
SQL_CALC_FOUND_ROWS
want to restrict the number of rows that a query returns, but also determine the number of rows
in the full result set without running the query again. An example is a Web script that presents
a paged display containing links to the pages that show other sections of a search result. Using
[960]
FOUND_ROWS()
the result.
The use of
SQL_CALC_FOUND_ROWS
statements than for simple
a UNION. It may be applied to individual
result as a whole.
Information Functions
CURRENT_USER()
[959]
returns the account for the object's invoker.)
returns the account for the user who defined the object. To return the
[964]
or
SESSION_USER()
[960]
returns NULL. Within a stored routine, the default database is
clause to restrict the number of rows the server returns to
LIMIT
option in the
SELECT
returns a number indicating how many rows the first
LIMIT
SQL_CALC_FOUND_ROWS
[960]
returns the number of rows in the result set returned by that
LIMIT
FOUND_ROWS()
or
LIMIT 50,
FOUND_ROWS()
SELECT SQL_CALC_FOUND_ROWS
SQL_CALC_FOUND_ROWS, MySQL must calculate how many rows are in
and
FOUND_ROWS()
enables you to determine how many other pages are needed for the rest of
and
FOUND_ROWS()
statements, because
SELECT
SELECT
960
[959]
returns the object's invoker.
characteristic, so for these objects,
SQL SECURITY
[964].
utf8
statement, and then invoke
clause.
option in the most recent successful
clause,
FOUND_ROWS()
[960]
returns 10 or 60, respectively, if the
10.
[960]
is transient and not intended to be available
[960]
can be useful in situations when you
[960]
is more complex for
may occur at multiple places in
LIMIT
statements in the UNION, or global to the
character set. If there is no
FOUND_ROWS()
would have
SELECT
SELECT
[960]
returns the number
statement. If you need to refer to
UNION
UNION
[960]

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents