MySQL POW function is one of the Mathematical Function which is used to find the first argument raised to power of the second argument.
In this article, we will show you, How to find the power of different 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);
This function will find the X raised to the power of Y.
MySQL POW Function Example 1
The POW Function is used to find and return the power of a number. The following query will show multiple ways to use 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 string but MySql will convert it into integer, and returns the output. However, Hi is a string and has no chance to find the Power so, it retuned 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 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;
Thank You for Visiting Our Blog