MySQL的format函数

mysql的format函数,可以格式化数据为整数或者浮点数。

mysql> select format(100.31111,2);
+---------------------+
| format(100.31111,2) |
+---------------------+
| 100.31              |
+---------------------+
1 row in set (0.00 sec)
 
mysql> select format(100.31111,0);
+---------------------+
| format(100.31111,0) |
+---------------------+
| 100                 |
+---------------------+
1 row in set (0.00 sec)
 
mysql> select format(100.51111,0);
+---------------------+
| format(100.51111,0) |
+---------------------+
| 101                 |
+---------------------+
1 row in set (0.00 sec)