MariaDB POWER() Function

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

POWER() is a synonym for POW().

MariaDB POWER() Syntax

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

POWER(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 'POWER'.

Return value

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

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

MariaDB POWER() Examples

Example 1

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

SELECT POWER(2, 3);

Output:

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

Example 2

Here is also a comprehensive example

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

Output:

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

Conclusion

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