如果我们要对POWER()
列的数据值使用函数,则第一个参数(即基数)将是列的名称,第二个参数(即指数)将由我们指定。为了理解它认为表'Employee'具有以下记录-
mysql> Select * from Employee; +----+--------+--------+ | ID | Name | Salary | +----+--------+--------+ | 1 | Gaurav | 50000 | | 2 | Rahul | 20000 | | 3 | Advik | 25000 | | 4 | Aarav | 65000 | | 5 | Ram | 20000 | | 6 | Mohan | 30000 | | 7 | Aryan | NULL | | 8 | Vinay | NULL | +----+--------+--------+ 8 rows in set (0.00 sec)
现在,下面的查询将提高列ID数据值的功效
mysql> Select ID, POWER(ID,2) from Employee; +----+-------------+ | ID | POWER(ID,2) | +----+-------------+ | 1 | 1 | | 2 | 4 | | 3 | 9 | | 4 | 16 | | 5 | 25 | | 6 | 36 | | 7 | 49 | | 8 | 64 | +----+-------------+ 8 rows in set (0.63 sec)