I must make an exponentiation of a number and I don't know which function to use between POW()
and POWER()
. Which of the two functions is better?
Looking at the MySQL documentation I saw that they are synonymous, but I wanted to understand if there was a reason for two functions that do the same thing.
POWER
is the synonym of POW
. So nothing is better, it is the same:
POWER(X,Y)
This is a synonym forPOW()
.
Using two different names for the same function gives you the possibility to port an SQL query from one dialect to an other dialect without (big) changes.
An example:
You want to use the following TSQL query on MySQL too:
SELECT POWER(2,2) -- 4
Now you can write these query specific for the dialects:
SELECT POWER(2,2) -- 4 - TSQL (POW is not available on TSQL)
SELECT POW(2,2) -- 4 - MySQL
But you can also use the POWER
function on MySQL since this is a synonym for POW
:
SELECT POWER(2,2) -- 4 - TSQL and MySQL