Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

SQRT() Function in MySQL

  • Last Updated : 28 Sep, 2020

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 :

Attention reader! Don’t stop learning now. Learn SQL for interviews using SQL Course  by GeeksforGeeks.

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 :

XX_Root
11
00
819
547.3484692283495345
65.428.088263101556477
-10NULL
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!