MySQL的format函数用法详解
2019/10/10/17:35:10 阅读:2649 来源:谷歌SEO算法 标签:
1号店SEO
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)
热门评论