位置:首页 > 数据库 > MySQL在线教程 > MySQL abs()函数

MySQL abs()函数

ABS(X)

ABS()函数返回X的绝对值,请考虑以下的例子:

mysql> SELECT ABS(2);
+---------------------------------------------------------+
| ABS(2)                                                  |
+---------------------------------------------------------+
| 2                                                       |
+---------------------------------------------------------+
1 row in set (0.00 sec)

mysql> SELECT ABS(-2);
+---------------------------------------------------------+
| ABS(2)                                                  |
+---------------------------------------------------------+
| 2                                                       |
+---------------------------------------------------------+
1 row in set (0.00 sec)