MySQL LN function is one of the Mathematical Function which is used to return the natural logarithmic value of a given number with base E. In this article we will show you, How to find logarithmic values in MySQL using Command Prompt, and Workbench with example.
MySQL LN Syntax
The basic syntax of the LN in MySQL is as shown below:
SELECT LN (x) FROM Source
If x is less than or equal to 0.0E0 then the function will return NULL value as output.
MySQL LN Function Example 1
The MySQL LN Function is used to return the natural logarithmic value of any numeric value. The following query will show multiple ways to use LN function.
-- MySQL LN Function Example SELECT LN(2); SELECT LN(0); SELECT LN(-5); SELECT LN(10);
MySQL LN Example 2
In MySQL, LN Function also allows you to find the logarithmic value of a column data. To demonstrate this LN function, we are going to use the below shown data
In this example, we are going to find the logarithmic values for all the records present in ServiceGrade column.
-- MySQL LN Example SELECT Product, Color, StandardCost, Sales, TaxAmt, ServiceGrade, LN(ServiceGrade) AS GradeLog FROM mysqltutorial.`numeric functions`;
Thank You for Visiting Our Blog