LOG

2023-10-24 09:23:03  Updated

Syntax

LOG([B,]X)

Purpose

You can call LOG(X) to return the natural logarithm of X, which is the base-e logarithm of X. If X is less than or equal to 0, the function returns NULL and reports the alert Invalid argument for logarithm. If only X is provided, this function is equivalent to LN(X).

You can call LOG(B,X) to return the logarithm of X to base B. If X is less than or equal to 0, or B is less than or equal to 1, the function returns NULL.

Examples

obclient> SELECT LOG(-10), LOG(0), LOG(10), LOG(-3.14), LOG(3.14);
+----------+--------+-------------------+------------+-------------------+
 LOG(-10)  LOG(0)  LOG(10)            LOG(-3.14)  LOG(3.14)         
+----------+--------+-------------------+------------+-------------------+
     NULL    NULL  2.302585092994046        NULL  1.144222799920162 
+----------+--------+-------------------+------------+-------------------+
1 row in set, 3 warnings (0.00 sec)

obclient> SELECT LOG(10, 100), LOG(1,100);
+--------------+------------+
 LOG(10, 100)  LOG(1,100) 
+--------------+------------+
            2        NULL 
+--------------+------------+
1 row in set, 1 warning (0.00 sec)

Contact Us