format函数在mysql中是数据内容格式化的,下面我来给各位介绍此函数的基本用法,希望此文章对各位所有帮助.
FORMAT()函数是用来在以下格式来格式化数X:###,###,#####截断至D位小数,下面的例子演示了如何使用和输出的FORMAT()函数,代码如下:
- mysql>SELECTFORMAT(423423234.65434453,2);
- +---------------------------------------------------------+
- |FORMAT(423423234.65434453,2)|
- +---------------------------------------------------------+
- |423,423,234.65|
- +---------------------------------------------------------+
- 1rowinset(0.00sec)
mysql的format函数,可以格式化数据为整数或者浮点数,代码如下:
- mysql>selectformat(100.31111,2);
- +---------------------+
- |format(100.31111,2)|
- +---------------------+
- |100.31|
- +---------------------+
- 1rowinset(0.00sec)
- mysql>selectformat(100.31111,0);
- +---------------------+
- |format(100.31111,0)|
- +---------------------+
- |100|
- +---------------------+
- 1rowinset(0.00sec)
- mysql>selectformat(100.51111,0);
- +---------------------+
- |format(100.51111,0)|
- +---------------------+
- |101|--phpfensi.com
- +---------------------+
- 1rowinset(0.00sec)