No, ^ is the Bitwise XOR operator in MySQL. For this, use POW() or POWER() from MySQL. Let us first create a table &minuns;
mysql> create table DemoTable ( BaseValue int, PowerValue float ); Query OK, 0 rows affected (0.48 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(4,1.9867); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(10,6.789); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(20,8.9); Query OK, 1 row affected (0.14 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-----------+------------+ | BaseValue | PowerValue | +-----------+------------+ | 4 | 1.9867 | | 10 | 6.789 | | 20 | 8.9 | +-----------+------------+ 3 rows in set (0.00 sec)
Following is the query to return the value of a number raised to the power of another number. Here, the Base Value and Power Value were inserted by us above −
mysql> select power(BaseValue,PowerValue) AS Result from DemoTable;
This will produce the following output −
+--------------------+ | Result | +--------------------+ | 15.707700779637127 | | 6151769.213414385 | | 379460404302.3042 | +--------------------+ 3 rows in set (0.00 sec)