MySQL POW() Function: Raise a number to a power

POW(base, exponent) calculates exponentiation in MySQL. POWER() is a synonym.

POW(): Quick SQL Example

Run this SELECT query directly in MySQL or phpMyAdmin. It uses fixed inputs so you can verify the result without creating a table.

SELECT POW(3, 4) AS power_value;
power_value
81
On this page — Show page sectionsHide page sections

More SQL Examples and Explanations

We can raise a number to a power with MySQL POW(). POWER() is a synonym for POW().
SELECT POW(5, 2);
Output of this is
25
For negative
SELECT POW(4, -2);
Output is
0.0625

Square table of number 1 to 10

We will develop a code to create square table of 1 to 10. We will be storing the data in mysql table.
Here is the code
require 'config.php'; // Database connection
$stmt = $dbo->prepare(
    'INSERT INTO sql_pow (a, b) VALUES (:a, POW(:base, 2))'
);

for ($i = 1; $i <= 10; $i++) {
    $stmt->execute(['a' => $i, 'base' => $i]);
}


Download SQL dump file of this table


SIN() function

How to Interpret the Result

An exponent can be negative. Use SQRT() for square roots and be careful with out-of-range results.

Common Question

Are POW() and POWER() different?
No. MySQL treats POWER() as a synonym for POW().

Further Reading

All Math Functions SQRT()

Database example: The PHP insertion sample above needs the matching table and a configured database connection. The standalone POW() queries do not.

More related tutorials: All math functions, COS(), DEGREES()

↑ Back to top




Subscribe to our YouTube Channel here



plus2net.com




SQL Video Tutorials










✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer