round(x,y)和format(x,y)

Posted bibiafa

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了round(x,y)和format(x,y)相关的知识,希望对你有一定的参考价值。

select round(123456.1456,2);
+----------------------+
| round(123456.1456,2) |
+----------------------+
|            123456.15 |
+----------------------+

select format(123456.1456,2);
+-----------------------+
| format(123456.1456,2) |
+-----------------------+
| 123,456.15            |
+-----------------------+

round()和format()都会对数值进行四舍五入,但是format()返回的是字符串,整数部分,每3位添加一个逗号。round()返回的仍然是数值

以上是关于round(x,y)和format(x,y)的主要内容,如果未能解决你的问题,请参考以下文章