How SIN() Works in MariaDB

In MariaDB, SIN() is a built-in numeric function that returns the sine of its argument, where its argument is provided in radians.

Syntax

The syntax goes like this:

SIN(X)

Where X is the value, expressed in radians, for which to return the sine.

Example

Here’s an example:

SELECT SIN(1.324980);

Result:

+--------------------+
| SIN(1.324980)      |
+--------------------+
| 0.9699389965228158 |
+--------------------+

Here are some more examples:

SELECT 
    SIN(0),
    SIN(-1),
    SIN(1);

Result:

+--------+---------------------+--------------------+
| SIN(0) | SIN(-1)             | SIN(1)             |
+--------+---------------------+--------------------+
|      0 | -0.8414709848078965 | 0.8414709848078965 |
+--------+---------------------+--------------------+

Non-Numeric Argument

Here’s what happens when we provide a non-numeric argument:

SELECT SIN('Two');

Result:

+------------+
| SIN('Two') |
+------------+
|          0 |
+------------+
1 row in set, 1 warning (0.000 sec)

Let’s check the warning:

SHOW WARNINGS;

Result:

+---------+------+-----------------------------------------+
| Level   | Code | Message                                 |
+---------+------+-----------------------------------------+
| Warning | 1292 | Truncated incorrect DOUBLE value: 'Two' |
+---------+------+-----------------------------------------+

Incorrect Parameter Count

Calling SIN() without an argument, or with too many arguments, results in an error.

Example:

SELECT SIN();

Result:

ERROR 1582 (42000): Incorrect parameter count in the call to native function 'SIN'

And:

SELECT SIN(1, 2);

Result:

ERROR 1582 (42000): Incorrect parameter count in the call to native function 'SIN'