MariaDB Tutorial MariaDB Advanced MariaDB Database Account Management MariaDB References

MariaDB LOG10() Function



The MariaDB LOG10() function returns the base-10 logarithm of a given number. In special cases it returns the following:

  • If the number is less than or equal to 0, then NULL is returned.

Syntax

LOG10(number)

Parameters

number Required. Specify the number. Must be greater than 0.

Return Value

Returns the base-10 logarithm of a given number.

Example 1:

The example below shows the usage of LOG10() function.

SELECT LOG10(1);
Result: 0

SELECT LOG10(2);
Result: 0.3010299956639812

SELECT LOG10(3);
Result: 0.47712125471966244

SELECT LOG10(10);
Result: 1

SELECT LOG10(15);
Result: 1.1760912590556813

SELECT LOG10(0);
Result: NULL

Example 2:

Consider a database table called Sample with the following records:

Datax
Data 10.5
Data 21
Data 35
Data 410
Data 550

The statement given below can be used to calculate the base-10 logarithm of column x.

SELECT *, LOG10(x) AS LOG10_Value FROM Sample;

This will produce the result as shown below:

DataxLOG10_Value
Data 10.5-0.3010299956639812
Data 210
Data 350.6989700043360189
Data 4101
Data 5501.6989700043360187

❮ MariaDB Functions