Tutorial Gateway

  • C
  • C#
  • Python
  • SQL
  • Java
  • JS
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Go Programs
    • Python Programs
    • Java Programs
  • MySQL

MySQL LOG Function

MySQL LOG function is one of the Mathematical Function, which helps return the natural logarithmic value of a given number. If we specify the base value, then it returns the log value with base.

In this section, we show how to find natural logarithmic values in MySQL using Command Prompt and Workbench with natural examples.

MySQL LOG Syntax

The basic syntax of the LOG in MySQL is as shown below:

SELECT LOG(X) FROM Source

SELET LOG(Base, X)

If you use this LOG function with a single argument, it returns the natural logarithmic value of X. And, if we use two arguments, the base log value will return.

MySQL LOG Function Example 1

The LOG function returns the natural logarithmic value. The following query will show multiple ways to use LOG function.

SELECT LOG(1);

SELECT LOG(100);

SELECT LOG(35000);
MySQL LOG Function 1

TIP: LOG(2, X) is same as LOG2(X) function and LOG(10, X) is same as LOG10(X) function.

Here, we are using the base argument of LOG Function. The first MySQL statement returns the base 2 logarithmic value of 10. Within the third statement, LOG(10, 1000) means base 10 Logarithmic value of 10000.

SELECT LOG(2,10);

SELECT LOG(2,1000);

SELECT LOG(2,10000), LOG(10, 10000), LOG(1, 10000);
MySQL LOG Function 2

MySQL LOG Example 2

The MySQL LOG Function also allows you to find the natural logarithmic value of a column data. In this Mathematical Function example, we are going to find the natural logarithmic value, base 2 logarithmic value and base 10 logarithmic values for all the records present in the Standard Cost column.

SELECT EnglishProductName,
      Color,
      StandardCost,
      LOG(StandardCost) AS LogStdCost,
      LOG(2, StandardCost) AS Log2StdCost,
      LOG(10, StandardCost) AS Log10StdCost
 FROM `MySQL Tutorial`.`mathemetical functions`;
MySQL LOG Function 3

Filed Under: MySQL

  • How to Download MySQL
  • Install MySQL on Windows
  • MySQL Create Database
  • MySQL Delete Database
  • MySQL Create Table
  • MySQL Drop Table
  • MySQL SELECT Statement
  • MySQL ALIAS Column
  • MySQL Distinct
  • MySQL Insert Statement
  • MySQL Delete
  • MySQL Truncate Table
  • MySQL WHERE Clause
  • MySQL Order By
  • MySQL Group By
  • MySQL Having Clause
  • MySQL LIMIT
  • MySQL Arithmetic Operators
  • MySQL COALESCE Function
  • MySQL AND Operator
  • MySQL NOT Operator
  • MySQL OR Operator
  • MySQL XOR Operator
  • MySQL BETWEEN Operator
  • MySQL Not Between Operator
  • MySQL GREATEST Function
  • MYSQL LEAST Function
  • MySQL LIKE Operator
  • MySQL NOT LIKE Operator
  • MySQL IFNULL Operator
  • MySQL NULLIF Operator
  • MySQL INTERVAL Operator
  • MySQL IS Operator
  • MySQL IN Operator
  • MySQL NOT IN Operator
  • MySQL IS NOT NULL
  • MySQL IS NULL
  • MySQL Inner Join
  • MySQL Cross Join
  • MySQL Right Join
  • MySQL Left Join
  • MySQL Aggregate Functions
  • MySQL Date Functions
  • MySQL Date Function
  • MySQL String Functions
  • MySQL Numeric Functions

Copyright © 2021ยท All Rights Reserved by Suresh.
About | Contact | Privacy Policy