MySQL TAN() FunctionLast 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. SyntaxParameter:number: It is the value for getting tangent. Returns:This function returns the tangent of a number. Example 1Explanation: 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.
Example 2Explanation: 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.
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.
Using the MySQL TAN() function in a TableThe 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.
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.
Using the MySQL TAN() function in a Table with Sin Value and Cosine ValueIn 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
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.
Using the MySQL TAN() function in a Table column with a WHERE clauseThe 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
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.
MySQL TAN function with UPDATE StatementIn 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.
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.
Next TopicMySQL Math |
We request you to subscribe our newsletter for upcoming updates.