MySQL SIN Function

MySQL SIN function is one of the Numeric Functions, which is useful to calculate the trigonometric sine value of the specified expression. The mathematical formula behind this Sine function is SIN(x) = Length of the Opposite Side / Length of the Hypotenuse. The basic syntax of the SIN in MySQL is as shown below:

SELECT SIN (Numeric_Expression)
FROM Source

To demonstrate this MySQL SIN Numeric function, we are going to use the below shown data

MySQL SIN Function 1

MySQL SIN Function Example 1

The MySQL Sine function returns the trigonometric sine value for any numeric value. The following query shows multiple ways to use the SIN function.

-- MySQL SIN Function Example

-- Sine of Negative Value
SELECT SIN(-15.35) AS `Sine Value`;

-- Sine of Positive Value
SELECT SIN(5.25) AS `Sine Value`;

-- Sine of Numeric Expression
SELECT SIN(2.25 + 2.75 - 5.00) AS `Sine Value`;

-- Sine of string value
SELECT SIN('9.73') AS `Sine Value`;

-- Sine of String
SELECT SIN('MySQL') AS `Sine Value`;

As you can from the screenshot below, we used the SIN function to find the Sine values for different values. And, we assigned a new name to the MySQL result as ‘ Sine Value’ using ALIAS Column.

MySQL SIN Function Example 2

MySQL SIN Example 2

The MySQL SIN Numeric also allows you to find the sine values for the data in a table. In this example, we are going to find the sine for all the records present in the Tax Amount column and Service Grade column.

-- MySQL Sine Function Example
USE mysqltutorial;
SELECT Product, Color,
		StandardCost, Sales, TaxAmt,
        SIN(TaxAmt) AS `Tax Sine Value`,
        ServiceGrade,
        SIN(ServiceGrade) AS `Grade Sine Value`
FROM `numeric functions`;
MySQL SIN Function Example 3