好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

MySQL的format函数用法详解

src="/js/s2.js">

FORMAT()函数是用来在以下格式来格式化数X:###,###,#####截断至D位小数。下面的例子演示了如何使用和输出的FORMAT()函数:

 代码如下 复制代码

mysql>SELECT FORMAT(423423234.65434453,2);
+---------------------------------------------------------+
| FORMAT(423423234.65434453,2)                            |
+---------------------------------------------------------+
| 423,423,234.65                                          |
+---------------------------------------------------------+
1 row in set (0.00 sec)

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)

 补充: 数据库,mysql教程 

查看更多关于MySQL的format函数用法详解的详细内容...

  阅读:52次