General Functions

General functions operate on one or more discrete values. We have omitted a few rarely used functions with very specialized applications.

ABS( number )

Returns the absolute value of number (e.g., ABS(-10) returns 10).

ACOS( number )

Returns the inverse cosine of number in radians (e.g., ACOS(0) returns 1.570796).

ADDDATE( date, INTERVAL amount type )

Synonym for DATE_ADD.

ASCII( char )

Returns the ASCII value of the given character (e.g., ASCII('h') returns 104).

ASIN( number )

Returns the inverse sine of number in radians (e.g., ASIN(0) returns 0.000000).

ATAN( number )

Returns the inverse tangent of number in radians (e.g., ATAN(1) returns 0.785398).

ATAN2( X, Y )

Returns the inverse tangent of the point ( X , Y ) (for example, ATAN(-3,3) returns -0.785398).

BENCHMARK( num , function )

Runs function over and over num times and reports the total elapsed clock time.

BIN( decimal )

Returns the binary value of the given decimal number (e.g., BIN(8) returns 1000). This is equivalent to the function CONV(decimal,10,2) .

BIT_COUNT( number )

Returns the number of bits that are set to 1 in the binary representation of the number (e.g., BIT_COUNT(17) returns 2).

BIT_LENGTH( string )

Returns the number of bits in string (the number of characters times 8, for single-byte characters).

CASE value WHEN choice THEN returnvalue ... ELSE returnvalue END

Compares value to a series of choice values or expressions. The first choice to match the value ends ...

Get Managing & Using MySQL, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.