MySQL POWER() Function
The POWER()
function in MySQL calculates the result of raising a number to a specified power (exponent). This is a fundamental mathematical operation that's very useful in various calculations.
POWER(): Definition and Usage
POWER()
takes two numbers as input: the base number and the exponent. It returns the base number raised to the power of the exponent (baseexponent). This function is equivalent to the `POW()` function.
Syntax
Syntax
POWER(x, y)
Parameter Values
Parameter | Description |
---|---|
x |
The base number (the number being raised to a power). This is required. |
y |
The exponent (the power). This is required. |
Examples
Raising a Number to a Power
This example calculates 4 raised to the power of 2 (42 = 4 * 4 = 16).
Syntax
SELECT POWER(4, 2);
Output
16
Raising Another Number to a Power
This example calculates 8 raised to the power of 3 (83 = 8 * 8 * 8 = 512).
Syntax
SELECT POWER(8, 3);
Output
512