MySQL POWER Function

MySQL POWER function is one of the Numeric methods which calculates the power of the specified expression or numerical value. The syntax of the POW or POWER is as shown below:

SELECT POWER (Float_Expression, Value)
FROM Source

-- POW Function Syntax
SELECT POW (Float_Expression, Value)
FROM Source

To demonstrate these Numeric methods, we are going to use the below shown data

Source Table 1

MySQL POWER Function Example

This method returns the power of the first value by the second value, and the following query shows multiple ways to use this one.

-- POWER Function Example

-- Power of Negative Value
SELECT POWER(-10.00, 2) AS `Power Value`;

-- Power of Positive Value
SELECT POWER(5, 4) AS `Power Value`;

-- Power Function on string value
SELECT POWER('6', 3) AS `Power Value`;

-- Power Function on String
SELECT POWER('MySQL', 2) AS `Power Value`;

From the screenshot below, you can see, that we used the POWER function on different values. Here, we assigned a new name to the MySQL result as ‘Value’ using the ALIAS Column.

Example 2

MySQL POW Function Example

The POW Numeric Function is the synonym for the power function, and the following query shows you this one with examples.

-- POW Function Example

-- Power of Negative Value
SELECT POW(-2, 4) AS `Power Value`;

-- Power of Positive Value
SELECT POW(10, 3) AS `Power Value`;

-- Power Function on string value
SELECT POW('9', 2) AS `Power Value`;

-- Pow Function on String
SELECT POW('MySQL', 4) AS `Power Value`;

From the below screenshot, you can see that we used the POW function on different values.

POWER Example 3

The Numeric Functions POWER or POW also allows you to calculate the power for the column data. In this example, we are going to calculate the Power of all columns present in the Standard Cost, Sales, and tax amount column.

SELECT Product, Color,
		StandardCost, POWER(StandardCost, 2) AS Cost, 
        Sales, POWER(Sales, 2) AS Sales, 
        TaxAmt, POW(TaxAmt, 3) AS Tax
FROM `numeric functions`;
MySQL POWER Example 4