MySQL TAN() Function

Last Updated : 19 Feb 2026

The tan() is a Math function of MySQL. This function is used to get the tangent of the given number.

In MySQL, we can also find the tangent of an angle by dividing the sine value of an angle by the cosine value of an angle. In this article, we will explore the concept of MySQL TAN() function in detail along with its various practical examples.

Syntax

Parameter:

number: It is the value for getting tangent.

Returns:

This function returns the tangent of a number.

Example 1

Explanation: On the execution of above query, the tan() function returns the tangent value of the given angles.

Output: The output of this example is given below.

MySQL Math TAN() Function

Example 2

Explanation: On the execution of above query, the tan() function returns the tangent value of the given negative radians.

Output: The output of this example is given below.

MySQL Math TAN() Function

Example 3:

Explanation: On execution of the above query, in the TAN() function, we can pass the PI() function as an argument, returning the tangent value.

Output: The output of this example is given below.

RESULT
-1.2246467991473532e-16

Using the MySQL TAN() function in a Table

The MySQL TAN function is used to find the tangent value of given column value.

Follow the steps given below to perform the MySQL TAN() functionality in a table column.

Step 1: First, create a table named Math_Figure using the CREATE TABLE statement.

Step 2: After that INSERT data into a table using the INSERT TABLE statement.

Step 3: To check the information with the use of SELECT statement, whether the data is inserted or not.

IDDiagramAngleSin_ValueCosine_Value
1ABC0.5235990.50.866025
2PQR0.7853980.7071070.707107
3RST1.3090.9659270.258816
4DEF1.57081-000036199

Example:

Explanation: On execution of the above statement, the TAN function is used to return the tangent value of the Angle column in a table.

Output: The output of this example is given below.

IDDiagramAngleSin_ValueCosine_ValueTAN_VALUE
1ABC0.5235990.50.8660250.5773
2PQR0.7853980.7071070.7071070.9999
3RST1.3090.9659270.2588163.7320
4DEF1.57081-000036199-27624

Using the MySQL TAN() function in a Table with Sin Value and Cosine Value

In a MySQL table, we can also find the tangent of an angle by dividing the sine value of an angle by the cosine value of an angle.

Take the following example of Math_Figure Table which contains the following information

IDDiagramAngleSin_ValueCosine_Value
1ABC0.5235990.50.866025
2PQR0.7853980.7071070.707107
3RST1.3090.9659270.258816
4DEF1.57081-000036199

Example:

Explanation: On execution of the above statement, the TAN function is used to return the tangent value of the Angle column in a table.

Output: The output of this example is given below.

IDDiagramAngleSin_ValueCosine_ValueTAN_VALUE
1ABC0.5235990.50.8660250.5773
2PQR0.7853980.7071070.7071070.9999
3RST1.3090.9659270.2588163.7320
4DEF1.57081-000036199-27624

Using the MySQL TAN() function in a Table column with a WHERE clause

The MySQL TAN function is used to find the tangent value of a given column value with restricted data using the WHERE clause.

Sample Table: Math_Figure

IDDiagramAngleSin_ValueCosine_Value
1ABC0.5235990.50.866025
2PQR0.7853980.7071070.707107
3RST1.3090.9659270.258816
4DEF1.57081-000036199

Example:

Explanation: On execution of the above statement, the TAN function is used to return the tangent value from the Angle column in a Math_Figure table where the value of the ID column is greater than 1.

Output: The output of this example is given below.

IDDiagramAngleSin_ValueCosine_ValueTAN_VALUE
2PQR0.7853980.7071070.7071070.9999
3RST1.3090.9659270.2588163.7320
4DEF1.57081-000036199-27624

MySQL TAN function with UPDATE Statement

In MySQL, the TAN() function does not change the data in the table. With the use of the UPDATE statement we can update the data.

Take an example of the Math_Figure table, which contains the following information.

IDDiagramAngleSin_ValueCosine_Value
1ABC0.5235990.50.866025
2PQR0.7853980.7071070.707107
3RST1.3090.9659270.258816
4DEF1.57081-000036199

Syntax:

Example: Write a MySQL query to calculate the Tan value from the Angle column.

Step1: First, add a new column i.e. TAN_VALUE to the existing table using the ALTER statement.

Step2: After that use an UPDATE statement to set the value of the TAN_VALUE column.

Explanation: On execution of the above statement, the TAN function is used to return the tangent value from the Angle column in a Math_Figure table and the UPDATE statement is used to update the required changes in the table.

If you want to check whether the content is updated in the table or not, then use the following statement.

Output: After running this query, the output of the table is given below.

IDDiagramAngleSin_ValueCosine_ValueTAN_VALUE
1ABC0.5235990.50.8660250.5773
2PQR0.7853980.7071070.7071070.9999
3RST1.3090.9659270.2588163.7320
4DEF1.57081-000036199-27624

Next TopicMySQL Math