MySQL POW Function

MySQL POW function is one of the Mathematical methods, which is to find the first argument raised to the power of the second argument. How to find the power of different column values in using Command Prompt and Workbench with examples?.

The syntax of the POW in MySQL is as shown below:

SELECT POW(X, Y);

It finds the X raised to the power of Y.

MySQL POW Function Example

The POW Function finds and returns the power of a number. The following query shows multiple ways to use this.

First, we are finding the 2 raised to the power of 3 (2 * 2 * 2). Next, we are using Negative values. Within the third statement, we used 6 as a string, but it converts into integer and returns the output. However, Hi is a string and has no chance to find the Power, so MySQL returns 0.

SELECT POW(2, 3);

SELECT POW(4, -3), POW(-4, 5);

SELECT POW('6', 4), POW('HI', 5);
MySQL POW Function 1

The MySQL POW Function also allows you to find the power of a column data. In this Mathematical Function example, we are going to find the Yearly Income raised to the power of 2 and Sales raised to the power of 3.

SELECT EmpID, 
       FirstName,
       LastName,
       Occupation,
       YearlyIncome,
       POW(YearlyIncome, 2) AS PowIncome,
       Sales,
       POW(Sales, 3) AS PowSales
 FROM customer;
MySQL POW Function 2