Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • 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 LOG2 Function

by suresh

MySQL LOG2 function is one of the Mathematical functions used to return the logarithmic value of a given number with base 2. Let us see how to find base 2 logarithmic values in MySQL using Command Prompt, and Workbench with examples.

MySQL LOG2 Syntax

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

SELECT LOG2(x) FROM Source

MySQL LOG2 Function Example 1

The LOG2 Function returns the logarithmic value with base 2 of any numeric value. The following query shows multiple ways to use the LOG2 function.

SELECT LOG2(10);

SELECT LOG2(623250);

SELECT LOG2(250), LOG2(-150);
MySQL LOG2 Function 1

MySQL LOG2 Example 2

The MySQL LOG2 Mathematical functions also allows you to find the base 2 logarithmic value of a column data. In this MySQL example, we are going to find the base 2 logarithmic values for all the records present in Standard Cost, Sales Amount, and Tax Amount columns.

SELECT EnglishProductName, 
Color,
      StandardCost,
      LOG2( StandardCost) AS LogStdCost,
      SalesAmount,
      LOG2( SalesAmount) AS LogSalesAmount,
      TaxAmt,
     LOG2( TaxAmt) AS TaxAmt
 FROM `MySQL Tutorial`.`mathemetical functions`;
MySQL LOG2 Function 2

Placed 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 Us | Contact Us | Privacy Policy