Math Functions

MySQL math functions can be used to change the value of columns containing numeric values.

ABS( )

This MySQL function returns the absolute value of a given number.

ACOS( )

This MySQL function returns the arccosine, in radians, of a given number.

ACOS( )

This MySQL function returns the arccosine, in radians, of a given number.

ASIN( )

This MySQL function returns the arcsine, in radians, of a given number.

ASIN( )

This MySQL function returns the arcsine, in radians, of a given number.

ATAN( )

This MySQL function returns the arctangent, in radians, of a given number.

ATAN2( )

This MySQL function returns the arctangent, in radians, of X and Y for a point on a Cartesian plane.

BIT_COUNT( )

This MySQL function returns the number of bits set in the argument, which is an integer that the function treats as a binary number.

CEIL( )

This MySQL function rounds a given floating-point number up to the next higher integer.

CEILING( )

This MySQL function rounds a given floating-point number up to the next higher integer.

CONV( )

This MySQL function converts a number from one numeric base system to another.

COS( )

This MySQL function returns the cosine of number, where number is expressed in radians.

COT( )

This MySQL function returns the cotangent of a number.

DEGREES( )

This MySQL function converts radians to degrees.

EXP( )

This MySQL function returns the value of the natural logarithm base number e to the power of the given number.

FLOOR( )

This MySQL function rounds a given floating-point number down to the next lower integer.

This MySQL function returns the given floating-point number with a comma inserted between every three digits and a period before the number of decimal places specified in the second argument.

GREATEST( )

This MySQL function compares two or more values, returning the greatest value.

This MySQL function converts an Internet Protocol (IP) address in dot-quad notation to its numeric equivalent.

This MySQL function converts the numeric equivalent of an IP address to its dot-quad notation.

LEAST( )

Use this MySQL function to compare two or more values and return the smallest value.

LN( )

This MySQL function returns the natural logarithm of its input.

LOG( )

This MySQL function returns the logarithm of the first argument to the base indicated by the second argument.

LOG10( )

This MySQL function returns the base 10 logarithm of a given number.

LOG2( )

This MySQL function returns the base-two logarithm of a given number.

MOD( )

This MySQL function returns the remainder of a number given in the first argument when divided by the number given in the second argument, the modulo.

OCT( )

This MySQL function returns the octal or base 8 numeric system value of the given number.

PI( )

This MySQL function returns by default the first five decimal places of the number pi.

POW( )

This MySQL function returns the result of raising the number given in the first argument to the exponent given in the second argument.

POWER( )

This MySQL function returns the result of raising the number given in the first argument to the power of the number given in the second argument.

RADIANS( )

This MySQL function converts degrees to radians.

RAND( )

This MySQL function returns a random floating-point number from 0 to 1.

ROUND( )

This MySQL function rounds a number given in the first argument to the nearest integer.

SIGN( )

This MySQL function returns -1 if the given number is a negative, 0 if it is zero, and 1 if it is positive.

SIN( )

This MySQL function returns the sine of the number given, where number is expressed in radians.

This MySQL function returns the square root of its input, which must be a positive number.

TAN( )

This MySQL function returns the tangent of an angle, where number is expressed in radians.

TRUNCATE( )

This MySQL function returns a number equivalent to its first argument, removing any digits beyond the number of decimal places specified in the second argument.