MySQL POW function is one of the Mathematical Function, 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 MySQL using Command Prompt and Workbench with examples?.
MySQL POW Syntax
The syntax of the POW in MySQL is as shown below:
SELECT POW(X, Y);
The POW function finds the X raised to the power of Y.
MySQL POW Function Example 1
The POW Function finds and returns the power of a number. The following query shows multiple ways to use the POW function.
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 MySql converts it 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 Example 2
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.
POW(YearlyIncome, 2) AS PowIncome,
POW(Sales, 3) AS PowSales
FROM `MySQL Tutorial`.customer;