MySQL TAN function is one of the Numeric Functions, which is useful to calculate the trigonometric Tangent of the specified expression. The mathematical formula for this MySQL tangent function is TAN(x) = Length of the Opposite Side / Length of the Adjacent Side.
The basic syntax of the TAN in MySQL is as shown below:
SELECT TAN (Numeric_Expression) FROM Source
To demonstrate this TAN Numeric function, we are going to use the below shown data
MySQL TAN Function Example 1
The MySQL TAN returns the trigonometric tangent values for any numeric data. The following query shows multiple ways to use the TAN function.
-- MySQL TAN Function Example -- 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.
MySQL TAN Example 2
The TAN Numeric Function 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.
-- MySQL Tangent Example USE mysqltutorial; SELECT Product, Color, StandardCost, Sales, TaxAmt, ServiceGrade, TAN(ServiceGrade) AS `Grade Tangent Value` FROM `numeric functions`;
OUTPUT