LOG()
LOG(X) returns the natural logarithm of X.
Description
LOG(X) returns the natural logarithm of X.
Syntax
> LOG(X)
> LOG(B, X)
If called with one parameter, this function returns the natural logarithm of X. If called with two parameters, it returns the logarithm of X to the base B.
Arguments
| Arguments | Description |
|---|---|
| B | Optional. The base of the logarithm. |
| X | Required. Any numeric data type supported now. |
Examples
drop table if exists t1;
create table t1(a float, b float);
insert into t1 values(2,8);
mysql> select log(a), log(b) from t1;
+--------------------+--------------------+
| log(a) | log(b) |
+--------------------+--------------------+
| 0.6931471805599453 | 2.0794415416798357 |
+--------------------+--------------------+
1 row in set (0.00 sec)
mysql> select log(2, 8), log(10, 100);
+-----------+--------------+
| log(2, 8) | log(10, 100) |
+-----------+--------------+
| 3 | 2 |
+-----------+--------------+
1 row in set (0.00 sec)