×

MySQL LOG10() function

In this context, we will learn how we can use the MySQL LOG10() function with proper syntax and good examples.

Introduction of MySQL LOG10() function

To evaluate the natural logarithmic value of a mentioned number with base 10, we can use the LOG10() function in MySQL.

It will return NULL when the number is greater than 0.

Syntax of the MySQL LOG10() function

The syntax of the MySQL LOG10() function is given as follows:

LOG10(Y);

Parameters or arguments used in MySQL LOG10() function:

Only one parameter is accepted by LOG10() function, as mentioned above in the syntax and described below as follows.

Y– This is the number whose logarithm value with base e we want to calculate. It should be a positive number.

Returns:

It will return the natural logarithm of the given number Y with base 10.

The application used for LOG10() function:

The LOG10() function can be used in the given below MySQL versions:

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

Examples of MySQL LOG10() function:

Now, we will look into some examples of MySQL LOG10 functions.

Example 1:

Here, we will find the logarithm of the given numbers with base 10 using the LOG10() function in MySQL.

SELECT LOG10(1000) AS LOG10_Val;

Output:

LOG10_VAL
3
1 row in set (0.00 sec)

Example-2 :

Here, we will find the logarithm of 0 with base e using the LOG10() function in MySQL.

SELECT LOG10(0) AS LOG10_Val ;

Output:

LOG10_VAL
NULL
1 row in set (0.00 sec)

Example 3:

When we require to find the base 10 logarithmic value of a column data, then we can take the help of the LOG10 function. For demonstration, we have created a table named commodity.

CREATE TABLE Commodity(
Commodity_id INT AUTO_INCREMENT,
Commodity_name VARCHAR(100) NOT NULL,
Buying_price DECIMAL(13, 2) NOT NULL,
Selling_price DECIMAL(13, 2) NOT NULL,
Service_grade Decimal(6, 2) NOT NULL,
PRIMARY KEY(Commodity_id)
);

Now we will insert some data to the Commodity table –

INSERT INTO
Commodity(Commodity_name, Buying_price, Selling_price, Service_grade)
VALUES
('Touring Bike, '2019.00, 3009.6, 5.89 ),
('Mountain Bike,' 3019.50, 4000.56, 10.00 ),
('Road Bike,' 1019.20, 2000.56, -0.89 ),
('Road Bicycle,' 1419.50, 1800.56, -1.50 ),
('Racing Bicycle,' 3000.50, 4500.56, 5.00) ;

Now it will show all the commodity table data with the help of the following query -

Select * from Commodity;

COMMODITY_IDCOMMODITY_NAMEBUYING_PRICESELLING_PRICESERVICE_GRADE
1Touring Bike2019.003009.65.89
2Mountain Bike3019.504000.5610.00
3Road Bike1019.202000.56-0.89
4Road Bicycle1419.501800.56-1.50
5Racing Bicycle3000.504500.565.00

Now, we are going to find the logarithmic values with base 10 for all the records present in the Service_grade column.

Select Commodity_id, Commodity_name, Buying_price,
Selling_price, Service_grade, LOG10(Service_grade) AS GRADELOG10
FROM Commodity;

Output:

COMMODITY_IDCOMMODITY_NAMEBUYING_PRICESELLING_PRICESERVICE_GRADEGRADELOG10
1Touring Bike2019.003009.65.890.7701152947871016
2Mountain Bike3019.504000.5610.001
3Road Bike1019.202000.56-0.89NULL
4Road Bicycle1419.501800.56-1.50NULL
5Racing Bicycle3000.50   

Summary:

In this context, we have learned how we can use the MySQL LOG10() function to find the LOG10 values from given arguments respectively.


Related Topics

MySQL SELF JOIN

This join links table with itself. The inner join, a self join, a right join, and a cross join are connected with two or more two tables. But, the "self...

4 minutes read.

MySQL PERIOD_DIFF() function

In this context, we will learn how we can use the MySQL PERIOD_DIFF() function with proper syntax and good examples. Introduction of MySQL PERIOD_DIFF() function This function in MySQL is used to...

2 minutes read.

MySQL Character Length Function

In this context, we will learn how we can use the MySQL CHARACTER_LENGTH() function with proper syntax and good examples. Introduction of MySQL CHARACTER_LENGTH() function CHARACTER_LENGTH() function in MySQL is used to...

2 minutes read.

MySQL ASIN() Function

In this context we will learn how we can use the ASIN() function in MySQL with proper syntax and good example. Introduction of MySQL ASIN() function The arc sine value of a...

2 minutes read.

MySQL View

Introduction MySQL View is a virtual table to create a clone of the base table. The View does not contain its values or data. MySQL View creates to connect more than...

12 minutes read.

MySQL Join

The relational database system needs to interconnect multiple tables with each other. MySQL is a popular and easy data management system to connect multiple tables. The foreign key is used...

5 minutes read.

MySQL FROM_BASE64() function

In this context, we will learn how we can use the MySQL FROM_BASE64()() function with proper syntax and good examples. Introduction of MySQL FROM_BASE64()() function Basically, the FROM_BASE64() function In MySQL decodes...

2 minutes read.

MySQL RADIANS() function

In this context, we will learn how we can use the MySQL RADIANS() function with proper syntax and good examples. Introduction of MySQL RADIANS() function RADIANS() function in MySQL is used to...

2 minutes read.

MySQL Error 1046 - No Database Selected

What is MySQL? MySQL is a Relational Database Management System (RDBMS). SQL in MySQL is the abbreviation of "Structured Query Language", which Oracle developed it in 1995. It is one of...

1 minute read.

MySQL Math Function

The math function operates numerical values and displays required number data. The math function finds out sin, cos, tan values. Here, you find out the absolute value, reminder, and logarithmic...

6 minutes read.

MySQL Tutorial

In this tutorial, you will get information about the MySQL management system. This tutorial will cover the basic and advanced level MySQL concepts with examples that will help you become...

5 minutes read.

MySQL LENGTH() Function

In this context, we will learn how we can use the MySQL LENGTH() function with proper syntax and good examples. Introduction of MySQL LENGTH() function This function in MySQL is used to...

2 minutes read.

MySQL: Entity-Relationship Model

Entity-Relationship Model Entity-Relationship model or E R model is used to create a relationship between different attributes or entities. It describes the structure of the database with the help of the...

5 minutes read.

MySQL SOUNDEX() function

In this context, we will learn how we can use the MySQL SOUNDEX() function with proper syntax and good examples. Introduction of MySQL SOUNDEX() function SOUNDEX() function in MySQL is used to...

3 minutes read.

MySQL Features

Features of MySQL MySQL is a relational database management system (RDBMS): It is a collection of many programs and makes relations with many other programs. Easy to use MySQL database: MySQL...

2 minutes read.

MySQL Command line client Basic Queries

MySQL – command line client Basic Queries There are many queries to work with the MySQL command-line client. Today, we will explore MySQL basic queries and their function. The MySQL query...

8 minutes read.

MySQL Stored Procedure

MySQL creates the "stored procedure" function to operate database information. You can use parameters, blocks, and statements to create a new procedure. The procedure requires a database table to use...

3 minutes read.

MySQL COALESCE function

This statement displays the first non-null value of the table data. The COALESCE function returns a null value when all values of the table are null or do not find...

3 minutes read.

MySQL Triggers

MySQL trigger is a function of the stored procedure to respond to the system program. This function responds and runs any data table event automatically. You can use it for...

5 minutes read.

MySQL DAY() function

In this context, we will learn how we can use the MySQL DAY() function with proper syntax and good examples. Introduction of MySQL DAY() function This function in MySQL is used to...

2 minutes read.