MySQL - DEGREES() Function



MySQL provides a set of functions to perform various numerical functions. The DEGREES() function of MySQL converts an angle in degrees to radians.

Angles are measured in degrees and radians. One full revolution of a side equals 360 degrees, whereas the angle subtended by an arc with length 1 unit at the centre of the circle with radius 1 unit has a measure of 1 radian.

This function accepts a value representing radians as an argument, converts it in to degrees, and returns the result.

Syntax

Following is the syntax of MySQL DEGREES() function −

DEGREES(X);

Parameters

This function takes a numeric value representing an angle in radians as a parameter.

Return Value

This function returns the angle in degrees of the given value.

Example

The following query uses the DEGREES() function to convert the angle 180 degrees to its equivalent in radians −

SELECT DEGREES(180) As Result;

Output

This output is displayed as follows −

Result
10313.240312354817

Example

Here, we are converting the angle 90 degrees to its equivalent in radians −

SELECT DEGREES(90) As Result;

Output

This will produce the following result −

Result
5156.620156177409

Example

Apart from numeric values, you can also pass the degrees to this function as a string −

SELECT DEGREES('90') As Result;

Output

This output is displayed as follows −

Result
5156.620156177409

Example

Following example converts the value of PI() from radians to degrees. Here, value of PI() function is 3.14 −

SELECT DEGREES(PI()) As Result;

Output

This will produce the following result −

Result
180
Advertisements