Mysql Sqrt Function

MySQL: SQRT Function

This tutorial explains how to use the MySQL SQRT function with syntax and examples.

Description

The MySQL SQRT function returns the square root of a number.

Syntax

The syntax for the SQRT function in MySQL is:

SQRT( number )

Parameters or Arguments

number

A positive number used to calculate the square root.

Note

  • The SQRT function will return NULL, if the number is a negative value.

Applies To

The SQRT function can be used in the following versions of MySQL:

  • MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23

Example

Let's look at some MySQL SQRT function examples and explore how to use the SQRT function in MySQL.

For example:

mysql> SELECT SQRT(25);
Output: 5

mysql> SELECT SQRT(26);
Output: 5.0990195135927845

mysql> SELECT SQRT(0);
Output: 0

mysql> SELECT SQRT(-9);
Output: NULL