LAST_INSERT_ID
This function returns the last automatically generated value that was inserted into
an AUTO_INCREMENT column:

LAST_INSERT_ID()
RETURNS: int

GET_LOCK
This function tries to obtain a lock with a name given by the string str, with a time-
out of timeout seconds. It returns 1 if the lock was obtained successfully, 0 if the
attempt timed out, and NULL if an error occurred (such as running out of memory or
Appendix J: MySQL Function Reference 733

the thread being killed with mysqladmin kill). A lock is released, RELEASE_LOCK()
is executed, a new GET_LOCK() is executed, or the thread terminates.

GET_LOCK(str,timeout)
RETURNS: int

RELEASE_LOCK
This function releases the lock named by the string str that was obtained with
GET_LOCK(). It returns 1 if the lock was released, 0 if the lock wasnâ€™t locked by this
thread (in which case the lock is not released), and NULL if the named lock didnâ€™t
exist.

RELEASE_LOCK(str)
RETURNS: int

Functions for Use with
GROUP BY Clauses
Most of the functions used with the GROUP BY clause were covered in Chapter 3.
There are three additional functions that we did not cover there.

STD/STDDEV
This function returns the standard deviation of expr. It is an extension of ANSI
SQL. The STDDEV() form of this function is provided for Oracle compatibility.

STD(expr)

or

STDDEV(expr)
RETURNS: float

BIT_OR
This function returns the bitwise OR of all bits in expr. The calculation is performed
with 64-bit (BIGINT) precision.

BIT_OR(expr)
RETURNS: int
734 Part V: Appendixes

BIT_AND
This function returns the bitwise AND of all bits in expr. The calculation is per-
formed with 64-bit (BIGINT) precision.