MySQL SQRT() Function

The SQRT() function in MySQL calculates the square root of a number. The square root of a number is a value that, when multiplied by itself, equals the original number.



SQRT(): Definition and Usage

SQRT() is a fundamental mathematical function, commonly used in various calculations, especially those involving geometry, statistics, or any other area requiring square root computations. It's important to note that the input number must be non-negative (0 or positive); otherwise, you'll get an error.

Syntax

Syntax

SQRT(number)
      

Parameter Values

Parameter Description
number The number for which you want to calculate the square root. This is required and must be a non-negative number.

Examples

Calculating the Square Root of 64

This example calculates the square root of 64 (which is 8, because 8 * 8 = 64).

Syntax

SELECT SQRT(64);
      
Output

8.0000
      

Calculating the Square Root of 13

This example demonstrates calculating the square root of a number that is not a perfect square.

Syntax

SELECT SQRT(13);
      
Output

3.60555127546399
      

**Note:** The output values are approximate due to floating-point limitations. The precise value may vary slightly depending on your MySQL version. If you provide a negative number as input, you will receive an error.