In this tutorial, we will study the MySQL `RADIANS()`

and MySQL `DEGREES()`

functions. You must have come across radians and degrees as the two measures of angles in mathematics. The measures of angles are fundamental to geometry.

*Recommended read – MySQL SIN() and MySQL ASIN() functions*

Seeing this need, MySQL provides us with two functions – `RADIANS()`

and `DEGREES()`

.

- The
`RADIANS()`

function takes in a degree value as input and converts it to its radians equivalent. - The
`DEGREES()`

function does the exact opposite. It takes in a radians value as input and converts it to its degree equivalent.

Let us explore the syntax and examples of both these functions now.

Table of Contents

## Syntax of MySQL RADIANS()

```
RADIANS(number);
```

Where ‘number’ is the measure of an angle in degrees.

## Syntax of MySQL DEGREES()

```
DEGREES(number);
```

Where ‘number’ is the measure of an angle in radians.

## Examples of MySQL RADIANS()

Let us start by looking at a few basic examples. Let us find the value in radians of the following degree values – 120, 45 and 25.25 using the below queries.

```
SELECT RADIANS(120);
SELECT RADIANS(45);
SELECT RADIANS(25.25);
```

And we get the output as,

### MySQL RADIANS() With Negative Values

Let us now pass negative angle values in degrees to the `RADIANS()`

function. Consider the below queries.

```
SELECT RADIANS(-25);
SELECT RADIANS(-75.5);
```

And we get the output as,

### MySQL RADIANS() With Expressions

We can also pass expressions as arguments to `RADIANS()`

. Expressions may contain mathematical operators or even mathematical functions like PI(). Let us see this using the below queries.

```
SELECT RADIANS(50/2);
SELECT RADIANS(PI()/3);
```

And we get the output as follows.

### MySQL RADIANS() With NULL

`RADIANS()`

returns NULL if we pass NULL as an argument to it since a degree value cannot be NULL. Let us see this using the below example.

```
SELECT RADIANS(NULL);
```

And we get the output as,

## Examples Of MySQL DEGREES()

Let us now look at a few examples of MySQL `DEGREES()`

. How about we start with finding the degree equivalent of the following radian values – 1, 1.25 and 0.5? The queries for it are –

```
SELECT DEGREES(1);
SELECT DEGREES(1.25);
SELECT DEGREES(0.5);
```

And we get the output as follows –

### DEGREES() With Expressions

We can also pass expressions as arguments to the `DEGREES()`

function. Expressions may contain mathematical operators or even mathematical functions like `PI()`

. Let us see this using the below queries.

```
SELECT DEGREES(5/2);
SELECT DEGREES(5*0.003);
```

And we get the output as,

As you would have come across in maths, most radian values are expressed in terms of 𝜋. Let us find the degree equivalent of some of the radian values expressed in 𝜋.

```
SELECT DEGREES(PI()/6);
SELECT DEGREES(PI());
SELECT DEGREES(PI()/4);
```

And we get the output as follows –

### DEGREES() With Negative Values

What if you pass a negative value to `DEGREES()`

? Let us see an example of this.

```
SELECT DEGREES(-0.5);
SELECT DEGREES(-PI()/2);
```

And we get the output as –

### MySQL DEGREES() With NULL

MySQL `DEGREES()`

returns NULL if we pass NULL as an argument to it since a radians value cannot be NULL. Let us see this using the below example.

```
SELECT DEGREES(NULL);
```

And we get the output as,

## MySQL DEGREES() and RADIANS() With Tables

Consider the below Angles table where the Angle column contains the measure of angles in radians.

Let us start by displaying the Angle column and its values equivalent in degrees. We do so using the below query.

```
SELECT Angle, DEGREES(Angle) AS AngleInDegrees FROM Angles;
```

And we get the output as,

Let us cross-check the above output by passing the `DEGREES()`

function inside the `RADIANS()`

function. Yes, that is allowed. As I said, we can include any mathematical function as an argument to these functions. Anyway, our query is –

```
SELECT Angle, RADIANS(DEGREES(Angle)) AS AngleInRadians FROM Angles;
```

And the output is –

Bingo! The values in both columns match.

## Conclusion

Converting angle values from degree to radians and radians to degrees is an important operation. We as humans, find it easier to use the degree notation while expressing the measures of angles. However, the trigonometric functions like `SIN()`

and so on, take the input of the measure of angles in radians only. Hence, these two functions prove quite important.