POWER()

Description

POWER(X, Y) returns the value of X raised to the power of Y.

Syntax

  1. > POWER(X, Y)

Arguments

ArgumentsDescription
XRequired. Any numeric data type supported now.
YRequired. Any numeric data type supported now.

Examples

  1. drop table if exists t1;
  2. create table t1(a int,b int);
  3. insert into t1 values(5,-2),(10,3),(100,0),(4,3),(6,-3);
  4. mysql> select power(a,b) from t1;
  5. +----------------------+
  6. | power(a, b) |
  7. +----------------------+
  8. | 0.04 |
  9. | 1000 |
  10. | 1 |
  11. | 64 |
  12. | 0.004629629629629629 |
  13. +----------------------+
  14. 5 rows in set (0.01 sec)
  15. mysql> select power(a,2) as a1, power(b,2) as b1 from t1 where power(a,2) > power(b,2) order by a1 asc;
  16. +-------+------+
  17. | a1 | b1 |
  18. +-------+------+
  19. | 16 | 9 |
  20. | 25 | 4 |
  21. | 36 | 9 |
  22. | 100 | 9 |
  23. | 10000 | 0 |
  24. +-------+------+
  25. 5 rows in set (0.01 sec)