Open In App

SQRT() Function in MySQL

Last Updated : 28 Sep, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

SQRT() is function in MySQL is used to return Returns the square root of a given non-negative number. If the number is negative then it returns NULL.

Syntax :

SQRT(X)

Parameter :
SQRT function in MySQL accepts one parameter and gives the result on the basis of input. In the given below, you will see how you can give the input in function and what exactly it return after successful execution.

  • X – A number whose square root we want to calculate .

Returns –
It returns the square root of a given non-negative number.

Example-1 :
Applying SQRT() function to a square number.

SELECT SQRT(4) AS Root_Val;

Output :

Root_Val
2

Example-2 :
Applying SQRT() function to a non-square number.

SELECT SQRT(14) AS Root_Val;

Output :

Root_Val
3.7416573867739413

Example-3 :
Applying SQRT() function to a negative number.

SELECT SQRT(-14) AS Root_Val;

Output :

Root_Val
NULL

Example-4 :
Applying SQRT() function to a numeric column in a table.

Table -Number

X
1
0
81
54
65.42
-10
SELECT X, SQRT(X) AS X_Root  FROM Number ;

Output :

X X_Root
1 1
0 0
81 9
54 7.3484692283495345
65.42 8.088263101556477
-10 NULL

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads