MariaDB SQRT() Function

In MariaDB, SQRT() is a built-in numeric function that returns the square root of a given number.

MariaDB SQRT() Syntax

Here is the syntax of the MariaDB SQRT() function:

SQRT(number)

Parameters

number

Required. A number used to calculate the logarithm. The value must be greater than 0.

If you provide the wrong number of parameters, MariaDB will report an error: ERROR 1582 (42000): Incorrect parameter count in the call to native function 'SQRT'.

Return value

The MariaDB SQRT() function returns number the .

If the parameter number is negative or NULL, the SQRT() function will return NULL.

MariaDB SQRT() Examples

This statement shows the basic usage of the MariaDB SQRT() function:

SELECT
    SQRT(16),
    SQRT(25),
    SQRT(49),
    SQRT(100),
    SQRT(101),
    SQRT(-100),
    SQRT(NULL)\G

Output:

  SQRT(16): 4
  SQRT(25): 5
  SQRT(49): 7
 SQRT(100): 10
 SQRT(101): 10.04987562112089
SQRT(-100): NULL
SQRT(NULL): NULL

Conclusion

In MariaDB, SQRT() is a built-in numeric function that returns the square root of a given number.