How to Convert radians to degrees using DEGREES() in MySQL8 ?
With MySQL, we can do complex calculations very easily with the help of inbuilt mathematical functions. DEGREES(X) helps in converting argument X, from radians to degrees.
Now let’s start with it.
DEGREES(X) is a mathematical function. It changes the input value in radians which are passed as the argument, to degrees.
It will return NULL, if X is passed as NULL.
It returns Error, if any String argument is passed as an input.
MySQL DEGREES() : Syntax
MySQL DEGREES() : Parameter
Name, Required /Optional, Description
X , Required, Double , It represents a valid number.
MySQL DEGREES() : Output
Return, Description
NULL, if the argument is NULL.
Double, It returns converting degree value of argument X passed as radians.
MySQL DEGREES() Available from : MySQL 4.1
DEGREES() Example 1 : Basic Examples
Now, Let’s see some of the basic examples of it and see what it returns.
mysql> SELECT DEGREES(500); +-------------------+ | DEGREES(500) | +-------------------+ | 28647.88975654116 | +-------------------+ 1 row in set (0.00 sec) mysql> SELECT DEGREES(2.5); +-------------------+ | DEGREES(2.5) | +-------------------+ | 143.2394487827058 | +-------------------+ 1 row in set (0.04 sec) mysql> SELECT DEGREES(12.5); +-------------------+ | DEGREES(12.5) | +-------------------+ | 716.1972439135291 | +-------------------+ 1 row in set (0.00 sec)
DEGREES() Example 2 : Using it with PI()
We are using the PI() function to get the value of DEGREES() of it. I get the below value.
mysql> SELECT DEGREES(PI()); +---------------+ | DEGREES(PI()) | +---------------+ | 180 | +---------------+ 1 row in set (0.07 sec)
DEGREES() Example 3 : Using it Expressions
We are using the PI() function to get the value of DEGREES() of it. I get the below value.
mysql> SELECT DEGREES(PI()/2); +-----------------+ | DEGREES(PI()/2) | +-----------------+ | 90 | +-----------------+ 1 row in set (0.05 sec)
mysql> SELECT DEGREES(PI()*2); +-----------------+ | DEGREES(PI()*2) | +-----------------+ | 360 | +-----------------+ 1 row in set (0.00 sec) mysql> SELECT DEGREES(PI()/4); +-----------------+ | DEGREES(PI()/4) | +-----------------+ | 45 | +-----------------+ 1 row in set (0.00 sec)
DEGREES() Example 4 : NULL arguments
If the argument is NULL, it will return NULL. See the below example :
mysql> SELECT DEGREES(NULL); +---------------+ | DEGREES(NULL) | +---------------+ | NULL | +---------------+ 1 row in set (0.01 sec)