MySQL SIN() Function – Return the Sine of a Number in MySQL

In MySQL, the SIN() function returns the sine of a given value, where the value is given in radians.

The sine is a trigonometric function of an angle. The sine of an acute angle is defined in the context of a right triangle: for the specified angle, it is the ratio of the length of the side that is opposite that angle to the length of the longest side of the triangle (the hypotenuse).

Syntax

The syntax goes like this:

SIN(X)

Where X is the value for which you’d like the sine returned.

Example 1 – Basic Usage

Here’s a basic example to demonstrate what SIN() returns for a given value.

SELECT SIN(3);

Result:

+--------------------+
| SIN(3)             |
+--------------------+
| 0.1411200080598672 |
+--------------------+

Example 2 – Negative Value

Here’s an example using a negative value.

SELECT SIN(-3);

Result:

+---------------------+
| SIN(-3)             |
+---------------------+
| -0.1411200080598672 |
+---------------------+

Example 3 – Using PI

In this example, I get the sine of π (pi). I do this by passing in the PI() function as an argument.

SELECT SIN(PI());

Result:

+------------------------+
| SIN(PI())              |
+------------------------+
| 1.2246467991473532e-16 |
+------------------------+