©SQL :: Manager
HomeProgram InformationTechnical detailsFree downloadDonate for a cup of coffee
myway SQL Manager for MySQL and MariaDB, Download on Uptodown
SQL functionMySQLMariaDB

The LOG SQL Function in MySQL and MariaDB - Logarithm to the base

LOGSyntax:LOG([Base], Number)
Return value:FLOAT
Synonyms:LN
Function type:Numeric function
Function Description

If the "Base" is not specified, the LOG() function returns the natural logarithm of "Number".

If the value of "Number" is less than or equal to 0, NULL is returned.


If the "Base" is specified, it returns the logarithm of "Number" to the "Base".

If "Base" is less than or equal to 1 or "Number" is less than or equal to 0, NULL is returned.


If "Number" or "Base" is NULL, NULL is returned.

The reverse function without "Base" is the EXP() function.

Examples without specifying the base

 1
 2
 3
 4
 5

select log(2.4) as result;
select log(2) as result;
select log(-2) as result;

result
double(23)
0.8754687373538999
result
double(23)
0.6931471805599453
result
double(23)
NULL

Examples with specifying the base

 1
 2
 3
 4
 5

select log(2,2) as result;
select log(4,2) as result;
select log(16,2) as result;

result
double(23)
1
result
double(23)
0.5
result
double(23)
0.25
The examples were created with the MyWAY SQL manager: Download

How to use the LOG() function in MySQL and MariaDB databases

The LOG() function in MySQL and MariaDB can be used to calculate the logarithm with different bases, including the natural logarithm (base e). The function is widely used in various mathematical and scientific calculations, such as calculating exponential growth rates or decay rates, solving equations with logarithms, or working with logarithmic scales. The LOG() function uses floating point arithmetic, so the precision of the result depends on the underlying data type.
LOCALTIMELOCALTIMESTAMPLOCATELOGLOG10LOG2LOWER

Further MySQL und MariaDB SQL Numeric functions

BIT_COUNTBIT_COUNT(Integer)
More about BIT_COUNT Function

CEILCEIL(Number)
More about CEIL Function

CEILINGCEILING(Number)
More about CEILING Function

CRC32CRC32(String)
More about CRC32 Function

CRC32CCRC32C([Parameter], String)

FLOORFLOOR(Number)
More about FLOOR Function

SIGNSIGN(Number)
More about SIGN Function

ABSABS(Number)
More about ABS Function

ACOSACOS(Number)
More about ACOS Function

ASINASIN(Number)
More about ASIN Function

ATANATAN(Number [, Number2])
More about ATAN Function

ATAN2ATAN2(Number [, Number2])
More about ATAN2 Function

COSCOS(Number)
More about COS Function

COTCOT(Number)
More about COT Function

DEGREESDEGREES(Number)
More about DEGREES Function

EXPEXP(Number)
More about EXP Function

LNLN(Number)
More about LN Function

LOG10LOG10(Number)
More about LOG10 Function

LOG2LOG2(Number)
More about LOG2 Function

MODMOD(Number, Divider)
More about MOD Function

POWPOW(Number, Exponent)
More about POW Function

POWERPOWER(Number, Exponent)
More about POWER Function

PIPI()
More about PI Function

RADIANSRADIANS(Number)
More about RADIANS Function

RANDRAND([Number])
More about RAND Function

ROUNDROUND(Number [, Decimals])
More about ROUND Function

SINSIN(Number)
More about SIN Function

SQRTSQRT(Number)
More about SQRT Function

TANTAN(Number)
More about TAN Function

TRUNCATETRUNCATE(Number, Decimals)
More about TRUNCATE Function

Numeric functionsString functionsRegular ExpressionsDate and Time functions
Comparison functionsEncryption & CompressionConversion functionsNULL functions
Aggregate functionsWindow functionsJSON functionsGeometric functions
Sequence functionsInformation functionsDynamic ColumnsMiscellaneous functions
More information about the LOG SQL function: mysql.com and mariadb.com and w3schools.com
Updated: 2023-09-24ImprintContactTerms & conditionsPrivacy & CookiesUpdatesSitemapFacebookLinkedinTwitterStatistics©2020-2024 Heino Cunze-Fischer