MySQL LOG() Function
In MySQL, the LOG() function returns the logarithm of the specified number to the specified base.
LOG() Syntax
Here is the syntax of MySQL LOG() function:
LOG(number)
LOG(base, number)
LOG(number) A function is equivalent to a LN(number) function.
Parameters
number- Required. A number whose value must be greater than
0. base- Optional. The base whose value must be greater than
1.
Return value
In MySQL, the LOG() function returns the logarithm of the specified number to the specified base.
- If
numberis less than or equal to0, theLOG()function will returnNULL. - If
baseis less than or equal to1, theLOG()function will returnNULL. - The
LOG()function will returnNULLif any parameter isNULL.
LOG() Examples
SELECT
LOG(1),
LOG(EXP(1), 1),
LOG(2),
LOG(EXP(1), 2),
LOG(2, 16),
LOG(10, 100),
LOG(0),
LOG(-1),
LOG(1, 10),
LOG(NULL)\G
output
LOG(1): 0
LOG(EXP(1), 1): 0
LOG(2): 0.6931471805599453
LOG(EXP(1), 2): 0.6931471805599453
LOG(2, 16): 4
LOG(10, 100): 2
LOG(0): NULL
LOG(-1): NULL
LOG(1, 10): NULL
LOG(NULL): NULL