FORMAT()为此使用方法。让我们首先创建一个表-mysql> create table DemoTable
-> (
-> Amount DECIMAL(10,2)
-> );
使用插入命令在表中插入一些记录-mysql> insert into DemoTable values(84848757.60);
mysql> insert into DemoTable values(95868685.50);
mysql> insert into DemoTable values(4242342.36);
使用select语句显示表中的所有记录-mysql> select *from DemoTable;
输出结果+-------------+
| Amount |
+-------------+
| 84848757.60 |
| 95868685.50 |
| 4242342.36 |
+-------------+
3 rows in set (0.00 sec)
以下是在MySQL中设置分隔符的查询-mysql> select format(Amount,2) from DemoTable;
输出结果+------------------+
| format(Amount,2) |
+------------------+
| 84,848,757.60 |
| 95,868,685.50 |
| 4,242,342.36 |
+------------------+
3 rows in set (0.00 sec)