MySQL functions
MySQL MySQL database function is provided by built-in functions. These built-in functions can help users more easily handle the data in the table.
Mathematical Functions
MySQL mathematical functions are commonly used in a class of functions. Mainly for processing digital, including integer and floating point numbers and the like.
ABS (x) function
ABS (x) function is used for the absolute value.
example:
6 and obtaining the absolute value of -13
SELECT ABS (6), ABS ( -13);
FLOOR (x) function
The FLOOR (x) function returns the largest integer less than or equal to x.
example:
Returns the maximum integer greater than n
SELECT FLOOR (-3.14), CEILING ( 0.618);
RAND () function
RAND () function returns a random number between 0 and 1. But the RAND () Returns the number is completely random.
example:
select rand(20);
PI () function
PI () function returns the pi.
example:
select pi();
TRUNCATE (x, y) function
TRUNCATE (x, y) function returns the value of y to x reserved bits after the decimal point.
example:
select truncate(1.223,1);
ROUND (x) and the function ROUND (x, y) function
The ROUND (x) function returns the nearest integer x, i.e. the x-rounded off; the ROUND (x, y) function returns the value of y to x reserved bits after the decimal point, rounding processing is required truncation.
example:
Returns the rounded value of n, d retention decimal (default value d 0)
SELECT round (-1.23);
SQRT (x) function
SQRT (x) function is used to find the square root.
example:
select sqrt(4);
ceiling(n)
Returns the smallest integer less than n
select ceiling (1.23);
sign(n)
Returns the signs of the parameters (or -1, 0. 1)
SELECT SiN (PI ());
mod(n,m)
Modulo operation returns the remainder of n is divided by m (the same operator%)
PS: take the remainder of the dividend-related negative result, the dividend is positive at a positive, negative dividend is negative.
SELECT MOD (2,3), - 10 % 4;
pow (x, y) / power (x, y)
Back power y of x
select pow (2,2);