MariaDB POW() Function

In MariaDB, POW(x, y) is a built-in function that returns x raised to the power of y.

POW() is a synonym for POWER().

MariaDB POW() Syntax

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

POW(x, y)

Parameters

x

Required. The base in power calculations.

y

Required. Exponent in power calculations.

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 'POW'.

Return value

The MariaDB POW(x, y) function calculates x raised to the power of y and returns the result.

If any parameter is NULL, the POW() function will return NULL.

MariaDB POW() Examples

Example 1

To calculate 2 to the power of 3, use the following statement with the MariaDB POW() function:

SELECT POW(2, 3);

Output:

+-----------+
| POW(2, 3) |
+-----------+
|         8 |
+-----------+

Example 2

Here is also a comprehensive example

SELECT
    POW(2, 0),
    POW(2, 2),
    POW(2, 4),
    POW(2.5, 2),
    POW(2, -2),
    POW(2, -4),
    POW(2, NULL),
    POW(NULL, 2),
    POW(NULL, NULL)\G

Output:

      POW(2, 0): 1
      POW(2, 2): 4
      POW(2, 4): 16
    POW(2.5, 2): 6.25
     POW(2, -2): 0.25
     POW(2, -4): 0.0625
   POW(2, NULL): NULL
   POW(NULL, 2): NULL
POW(NULL, NULL): NULL

Conclusion

In MariaDB, POW(x, y) is a built-in function that returns x raised to the power of y.