Is POW() better or POWER() in MySQL?


Both pow() and power() are synonyms. Let us see the syntax −

select pow(yourValue1,yourValue2);

OR

select power(yourValue1,yourValue2);

Now we will see some examples.

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 first create a table and look into the above concept thoroughly −

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 displaying usage 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 displaying usage 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)
raja
Published on 17-May-2019 16:19:11
Advertisements