![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
To return value of a number raised to the power of another number, we should use ^ operator in MySQL?
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)
Advertisements