MySQL LOG10() Function

The LOG10() function in MySQL is used to return the base-10 logarithm of a number.


Syntax

LOG10(number)

Definition and Usage

  • The LOG10() function calculates the logarithm of a number to the base 10 (common logarithm).
  • The number must be greater than 0 for the function to work.

Parameter Values

Parameter Description
number Required. A number greater than 0 for which the base-10 logarithm will be calculated.

Technical Details

  • Works in: From MySQL 4.0
  • Return Value: A floating-point value representing the logarithm of the number to base 10.

Examples

Example 1: Return the base-10 logarithm of 2

SELECT LOG10(2);

Result:

LOG10(2): 0.301030

Explanation: The base-10 logarithm of 2 is approximately 0.301030.


Example 2: Return the base-10 logarithm of 4.5

SELECT LOG10(4.5);

Result:

LOG10(4.5): 0.653213

Explanation: The base-10 logarithm of 4.5 is approximately 0.653213.


Example 3: Return the base-10 logarithm of 1000

SELECT LOG10(1000);

Result:

LOG10(1000): 3

Explanation: The base-10 logarithm of 1000 is 3, as 10^3 = 1000.


Related Functions

  • LOG(): Returns the natural logarithm of a number or logarithm of the number to a specified base.
  • LN(): Returns the natural logarithm of a number (same as LOG() with base e).
  • EXP(): Returns e raised to the power of the specified number.

Usage Notes

  • The LOG10() function is primarily used in scientific and engineering calculations that involve logarithms to base 10, commonly used in areas such as logarithmic scales, data compression, and signal processing.

Was this article helpful?