Function Reference

SQRT

Returns the square root of a number.

MySQL 8.4
SQRT(num)
num
Non-negative number
DOUBLE

Return value

A floating-point number (DOUBLE); NULL for a negative number

Examples

Square root of 4

MySQL 8.4
SELECT SQRT(4);
SQRT(4)
2

Root of a negative number

MySQL 8.4
SELECT SQRT(-4);
SQRT(-4)
<NULL>

Details

For a negative number MySQL returns NULL, while PostgreSQL gives an error. A root of another degree is calculated with POW and a fractional exponent.

See also

Where to learn