Site icon TestingDocs.com

MySQL Mathematical Functions

Overview

In this tutorial, we will learn about MySQL mathematical functions with examples. MySQL supports many in built functions. Mathematical functions are type of function that are mostly used for mathematical calculations.

MySQL Mathematical Functions

Some MySQL mathematical function are as follows:

Numeric Function
Description
EXP(X)

 

This function returns the value of e raised to the power of X.
The inverse of this function is LOG().
LN(X) This function returns the natural logarithm (the base-e logarithm) of X.
LOG(B,X) This function returns the logarithm of the base B of X.
LOG2(X) This function returns the base-2 logarithm of X.
LOG10(X)  This function returns the base-10 logarithm of X.
POWER(X,Y) or POW This function returns the value of X raised to the power of Y.
SQRT(X) This function returns the square root of X.
MOD(N,M) This function returns the remainder of N divided by M.(the Modulo operation. )

 

Examples

mysql> SELECT EXP(1);
+——————-+
| EXP(1) |
+——————-+
| 2.718281828459045 |
+——————-+
1 row in set (0.00 sec)

mysql> SELECT LOG10(100);
+————+
| LOG10(100) |
+————+
| 2 |
+————+
1 row in set (0.01 sec)

MySQL Tutorials

MySQL Tutorials on this website:

https://www.testingdocs.com/mysql-tutorials-for-beginners/

For more information on MySQL Database:

https://www.mysql.com/

Exit mobile version