MySQL选择将数字转换为数百万亿格式?
您可以使用FORMAT()
MySQL将数字转换为数百万亿的格式。让我们首先创建一个表-
mysql> create table DemoTable ( Value BIGINT );
使用插入命令在表中插入记录-
mysql> insert into DemoTable values(78000000000); mysql> insert into DemoTable values(10000000000); mysql> insert into DemoTable values(90000000000); mysql> insert into DemoTable values(450600000000);
使用select语句显示表中的所有记录-
mysql> select *from DemoTable;
这将产生以下输出-
+--------------+ | Value | +--------------+ | 78000000000 | | 10000000000 | | 90000000000 | | 450600000000 | +--------------+ 4 rows in set (0.00 sec)
以下是将数字转换为百万和十亿格式的查询-
mysql> select format(Value,0) as `FormatValue` from DemoTable;
+-----------------+ | FormatValue | +-----------------+ | 78,000,000,000 | | 10,000,000,000 | | 90,000,000,000 | | 450,600,000,000 | +-----------------+ 4 rows in set (0.00 sec)