MySQL TAN Function

MySQL TAN function is one of the Numeric Functions useful for calculating the trigonometric Tangent of the specified expression. The mathematical formula for this tangent function equals the Length of the Opposite Side / Length of the Adjacent Side.

The basic syntax of the MySQL TAN Function is as shown below:

SELECT TAN (Numeric_Expression)
FROM Source

To demonstrate this Numeric function, we are going to use the below-shown data

Numeric Table 1

MySQL TAN Function Example

The TAN returns the trigonometric tangent values for any numeric data, and the following query shows multiple ways to use this method.

-- Tangent of Negative Value
SELECT TAN(-5.64) AS `Tangent Value`;

-- Tangent of Positive Value
SELECT TAN(PI()) AS `Tangent Value`;

-- Tangent of Numeric Expression
SELECT TAN(6.55 + 5.95 - 7.15) AS `Tangent Value`;

-- Tangent of string value
SELECT TAN('2.76') AS `Tangent Value`;

-- Tangent of String
SELECT TAN('MySQL') AS `Tangent Value`;

As you can see, we used this TAN function to find the Tangent of different values.

Tangent Example

This Numeric method also allows you to find the tangent of the table data. In this MySQL example, we are going to find the tangent value for all the records present in the Service Grade column.

SELECT Product, Color,
		StandardCost, Sales, TaxAmt, 
        TAN(ServiceGrade) AS `Grade Tangent Value`
FROM `numeric functions`;
MySQL TAN Function Example 3