Mysql Math Function

Math Function involved in Mysql when we perform some operation on mathematical operator.

Mysql Math Function

Mysql Math Function

     

Math Function involved in Mysql when we perform some operation on mathematical operator.

Understand with Example

The Tutorial illustrate an example from 'Mysql Math Function'.The below Syntax help you to perform Math Function :

ABS(X): This is used to Returns the absolute value of X.

Query:

 

 

The Query abs(12) is used to return the absolute value of 12 as fieldname 'AbsoluteValue'.

mysql> select abs(12)as AbsolutValue;
+--------------+
| AbsolutValue |
+--------------+
|           12 |
+--------------+
1 row in set (0.00 sec)

Query:

mysql> select abs(-12)as AbsolutValue;
+--------------+
| AbsolutValue |
+--------------+
|           12 |
+--------------+
1 row in set (0.00 sec)

ACOS(1):This is used to returns the arc cosine of 1, that is, the value whose cosine is 1

mysql>  SELECT ACOS(1)as Arccosine;
+-----------+
| Arccosine |
+-----------+
|         0 |
+-----------+
1 row in set (0.02 sec)

ASIN(0.1):This is used to returns the arc sine of X, that is, the value whose sine is X

mysql>  SELECT ACOS(0.1)as Arcsine ;
+-----------------+
| Arcsine         |
+-----------------+
| 1.4706289056333 |
+-----------------+
1 row in set (0.00 sec)

ATAN(1):This is used to returns the arc tangent of 1, that is, the value whose tangent is 1.

mysql>  SELECT ATAN(1)as Arctangent  ;
+------------------+
| Arctangent       |
+------------------+
| 0.78539816339745 |
+------------------+
1 row in set (0.00 sec)

ATAN(-2,2):This is used to returns the arc tangent of the two variables -2 and 2.

mysql> SELECT ATAN(-2,2)as  Arctangent;
+-------------------+
| Arctangent        |
+-------------------+
| -0.78539816339745 |
+-------------------+
1 row in set (0.00 sec)

CEILING(2.23):This is used to returns the smallest integer value not less than 2.23.

mysql> SELECT CEILING(2.23)as SmallestInteger;
+-----------------+
| SmallestInteger |
+-----------------+
|               3 |
+-----------------+
1 row in set (0.00 sec)

COS(0):This is used to returns the cosine of 0, where 0 is given in radians.

mysql> SELECT COS(0)as Cosine;
+--------+
| Cosine |
+--------+
|      1 |
+--------+
1 row in set (0.00 sec)

COT(45):This is used to returns the cotangent of 45.

mysql>  SELECT COT(45)as cotangent ;
+------------------+
| cotangent        |
+------------------+
| 0.61736962378356 |
+------------------+
1 row in set (0.00 sec)

CRC32(expr):This query Computes a cyclic redundancy check value and returns a 32-bit unsigned value.

mysql> SELECT CRC32('Girish')as CRCVALUE;
+------------+
| CRCVALUE   |
+------------+
| 4143371692 |
+------------+
1 row in set (0.03 sec)

DEGREES(180):This is used to returns the argument PI( ), converted from radians to degrees.

mysql> SELECT DEGREES(PI())as DEGREE;
+--------+
| DEGREE |
+--------+
|    180 |
+--------+
1 row in set (0.00 sec)
mysql> SELECT DEGREES(PI()/2)as DEGREE;
+--------+
| DEGREE |
+--------+
|     90 |
+--------+
1 row in set (0.00 sec)

EXP(0):This is used to returns the value of e (the base of natural logarithms) raised to the power of  0.

mysql> SELECT EXP(0)as evalue;
+--------+
| evalue |
+--------+
|      1 |
+--------+
1 row in set (0.00 sec)

FLOOR(3.63):This is used Returns the largest integer value not greater than 3.63.

mysql> SELECT FLOOR(3.63)as largestIntegerValue;
+---------------------+
| largestIntegerValue |
+---------------------+
|                   3 |
+---------------------+
1 row in set (0.00 sec)

LOG(2):-returns the natural logarithm of 2.

mysql>  SELECT LOG(2)as LogValue;
+------------------+
| LogValue         |
+------------------+
| 0.69314718055995 |
+------------------+
1 row in set (0.00 sec)

LOG10(1OO):Returns the base-10 logarithm of 100.

mysql> SELECT LOG10(100)as base10value;
+-------------+
| base10value |
+-------------+
|           2 |
+-------------+
1 row in set (0.00 sec)

ROUND(1.9814,2):Rounds the argument (1.9814,2) to Ddecimal places

mysql> SELECT ROUND(1.9814, 2)as RoundedValue;
+--------------+
| RoundedValue |
+--------------+
|         1.98 |
+--------------+
1 row in set (0.00 sec)

SQRT(49):Returns the square root of a non-negative number 49.

mysql> SELECT SQRT(49)as SquareRoot;
+------------+
| SquareRoot |
+------------+
|          7 |
+------------+
1 row in set (0.00 sec)