MySQL COT() Function

Last Updated : 26 Feb 2026

The cot() is a Math function of MySQL. This function is used to get the cotangent of the given number. If the given number is 0, an error or NULL will be returned. In a right triangle, the cotangent of an angle is the length of the adjacent side divided by the length of the opposite side.

In MySQL, we can also find the cotangent of an angle by dividing its sine value by its cosine value. In this article, we will explore the concept of the MySQL COT() function in detail, along with several working examples.

Syntax

Parameters:

Num: It is the number to get cotangent value.

Returns

This function returns the cotangent of the given number.

Example 1

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

Output: The output of this example is given below.

MySQL Math COT() Function

Example 2

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

Output: The output of this example is given below.

MySQL Math COT() Function

Example 3

Explanation: On the execution of above query, the cot() function returns the cotangent value of given negative values.

Output: The output of this example is given below.

MySQL Math COT() Function

Example 3:

Explanation: On the execution of above query, in the COT() function we can pass the PI() function as an argument which returns the cotangent value.

Output: The output of this example is given below.

RESULT
-8.165619676597685e15

Using the MySQL COT() function in a Table

The MySQL COT function is used to find the cotangent value of given column value.

Follow the steps given below to perform the MySQL COT() 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.50.50.866025
2PQR10.7071070.707107
3RST50.9659270.258816
4DEF101-000036199
5XYZ500.50.866025

Example:

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

Output: The output of this example is given below.

IDDiagramAngleSin_ValueCosine_ValueCot_Value
1ABC0.50.50.8660251.830487721712452
2PQR10.7071070.7071070.6420926159343306
3RST50.9659270.2588160.2958129155327455
4DEF101-0000361991.5423510453569202
5XYZ500.50.8660251.830487721712452

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

In MySQL, we can find the cotangent of an angle by dividing the sine value of an angle with the cosine value of an angle.

Take a following example of "Math_Figure" table which contains the following information.

IDDiagramAngleSin_ValueCosine_Value
1ABC0.50.50.866025
2PQR10.7071070.707107
3RST50.9659270.258816
4DEF101-000036199
5XYZ500.50.866025

Example:

Explanation: On execution of the above statement, by dividing the sine value of an angle with the cosine value of an angle to return the cotangent value.

Output: The output of this example is given below.

IDDiagramAngleSin_ValueCosine_ValueCot_Value
1ABC0.50.50.8660251.830487721712452
2PQR10.7071070.7071070.6420926159343306
3RST50.9659270.2588160.2958129155327455
4DEF101-0000361991.5423510453569202
5XYZ500.50.8660251.830487721712452

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

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

Sample Table: Math_Figure

IDDiagramAngleSin_ValueCosine_Value
1ABC0.50.50.866025
2PQR10.7071070.707107
3RST50.9659270.258816
4DEF101-000036199
5XYZ500.50.866025

Example:

Explanation: On execution of the above statement, the COT function is used to return the cotangent 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_ValueCot_Value
2PQR10.7071070.7071070.6420926159343306
3RST50.9659270.2588160.2958129155327455
4DEF101-0000361991.5423510453569202
5XYZ500.50.8660251.830487721712452

MySQL COT function with UPDATE Statement

In MySQL, the COT() 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.50.50.866025
2PQR10.7071070.707107
3RST50.9659270.258816
4DEF101-000036199
5XYZ500.50.866025

Syntax:

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

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

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

Explanation: On execution of the above statement, the COT function is used to return the cotangent 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_ValueCot_Value
1ABC0.50.50.8660251.830487721712452
2PQR10.7071070.7071070.6420926159343306
3RST50.9659270.2588160.2958129155327455
4DEF101-0000361991.5423510453569202
5XYZ500.50.8660251.830487721712452

Next TopicMySQL Math