Mysql Ln Function

MySQL: LN Function

This tutorial explains how to use the MySQL LN function with syntax and examples.

Description

The MySQL LN function returns the natural logarithm of a number.

Syntax

The syntax for the LN function in MySQL is:

LN( number )

Parameters or Arguments

number

The number to calculate the natural logarithm of. Must be greater than 0.

Note

  • The LN function will return NULL, if number is less than or equal to 0.
  • See also the LOG and EXP functions.

Applies To

The LN function can be used in the following versions of MySQL:

  • MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23

Example

Let's look at some MySQL LN function examples and explore how to use the LN function in MySQL.

For example:

mysql> SELECT LN(1);
Output: 0

mysql> SELECT LN(2);
Output: 0.6931471805599453

mysql> SELECT LN(2.5);
Output: 0.9162907318741551

mysql> SELECT LN(0);
Output: NULL

mysql> SELECT LN(-1);
Output: NULL