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) |