MySQL POWER Function

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

-- MySQL POWER Function Syntax
SELECT POWER (Float_Expression, Value)
FROM Source

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

To demonstrate the POW or POWER Numeric function, we are going to use the below shown data

MySQL POWER Function 1

MySQL POWER Function Example 1

The MySQL POWER returns the power of the first value by the second value. The following query shows multiple ways to use the POWER function.

-- MySQL 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, we used POWER function on different values. Here, we assigned a new name to the MySQL result as ‘Power Value’ using the MySQL ALIAS Column.

MySQL POWER Example 2

MySQL POW Function Example

The MySQL POW Numeric Function is the synonym for the power function. The following query shows you the POW function examples.

-- MySQL 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 POW function on different values.

MySQL POWER Example 3

MySQL POWER Example 2

The MySQL 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.

-- MySQL POWER Example OR MySQL POW Example
USE mysqltutorial;
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