Syntax error Which one is better POW() or POWER() in MySQL?

Which one is better POW() or POWER() in MySQL?



Both pow() and power() are synonyms in MySQL. Following is the syntax −

select pow(yourValue1,yourValue2);
OR
select power(yourValue1,yourValue2);

Let us implement both the above syntaxes.

Using POW()

mysql> select POW(4,3);

This will produce the following output −

+----------+
| POW(4,3) |
+----------+
| 64       |
+----------+
1 row in set (0.00 sec)

Using POWER()

mysql> select POWER(4,3);

This will produce the following output −

+------------+
| POWER(4,3) |
+------------+
| 64         |
+------------+
1 row in set (0.00 sec)

Let us implement the above syntax in a table −

mysql> create table DemoTable
   (
   a int,
   n int
   );
Query OK, 0 rows affected (0.51 sec)

Insert some records in the table using insert command −

mysql> insert into DemoTable values(10,3);
Query OK, 1 row affected (0.18 sec)

Display all records from the table using select statement −

mysql> select * from DemoTable;

This will produce the following output −

+------+------+
| a    | n    |
+------+------+
| 10   | 3    |
+------+------+
1 row in set (0.00 sec)

Following is the query of POW() −

mysql> select POW(a,n) from DemoTable;

This will produce the following output −

+----------+
| POW(a,n) |
+----------+
| 1000     |
+----------+
1 row in set (0.02 sec)

Following is the query of POWER() −

mysql> select POWER(a,n) from DemoTable;

This will produce the following output −

+------------+
| POWER(a,n) |
+------------+
| 1000       |
+------------+
1 row in set (0.00 sec)
Updated on: 2019-07-30T22:30:26+05:30

185 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements