×

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 DATE_FORMAT() function

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

3 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 Database Introduction

MySQL - Database Introduction: The database plays an essential role in MySQL for storing and modifying the data. The database creates and keeps multiple tables. The database organizes and manipulates...

8 minutes read.

MySQL Unique index

It helps to maintain data integrity to enforce the uniqueness of values in one or more columns. We can create more than one UNIQUE index in a single table, which...

3 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 variable

The MySQL variable is essential for storing data in the table. The variable declares data with a specific name or label to avoid confusion. This data label is used in...

6 minutes read.

MySQL ISNULL function

This function is used to check the null value in table data. It returns the result in a Boolean form. If table data is null, then the output becomes 1....

2 minutes read.

MySQL MIN function

The MIN() function determines the minimum or lowest value of the data set. This function works on numerical data type values. If the table displays zero value, then the row...

4 minutes read.

MySQL Subquery

The subquery is a MySQL query used to manage data operations. Mainly subquery helps to retrieve data with the necessary condition. It creates a nested query with two different queries....

5 minutes read.

MySQL RIGHT JOIN

MySQL right join links two tables with each other. The left table column connects with the complete right side table. Each row of the right table tries to connect with...

4 minutes read.

find_in_set() function in MySQL

This Function is used for finding the position of a particular string from the list of strings. For suppose if the specified string is repeated multiple times, then this functions...

4 minutes read.

MySQL UPDATE JOIN

The UPDATE JOIN is a MySQL statement used to perform cross-table updates that means we can update one table using another table with the JOIN clause condition. The "update join"...

5 minutes read.

MySQL Operators

MySQL Operators MySQL operator needs advanced operation on the table and its data. This operator works with the "WHERE" clause. MySQL operators are a statement to modify information. It helps to...

13 minutes read.

MySQL function

MySQL function is a piece of program to perform some specific task. Here we pass a parameter and then return a single value. MySQL function mainly supports string, numeric, conditional,...

9 minutes read.

MySQL Prefix index

Prefix index This index query creates an index column in the string or character column. MySQL system can create multiple indexes in the table. It will create in a table as...

3 minutes read.

MySQL QUARTER() function

In this context, we will learn how we can use the MySQL QUARTER() function with proper syntax and good examples. Introduction of MySQL QUARTER() function The QUARTER() function in MySQL returns the...

3 minutes read.

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...

2 minutes read.

MySQL ROUND() function

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

3 minutes read.

MySQL INSERT() Function

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

2 minutes read.

MySQL logical conditions

MySQL logical conditions Introduction MySQL handles data with clauses, operators, and conditions. The logical condition is used to compare information and returns the required output. This condition applies logic to MySQL expressions...

7 minutes read.