Como colocar separador de mil em registros MySQL?
Use o método FORMAT() para isso. Vamos primeiro criar uma tabela:
mysql> create table DemoTable
-> (
-> Amount DECIMAL(10,2)
-> );
Query OK, 0 rows affected (0.45 sec)
Insira alguns registros na tabela usando o comando insert:
mysql> insert into DemoTable values(84848757.60);
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable values(95868685.50);
Query OK, 1 row affected (0.15 sec)
mysql> insert into DemoTable values(4242342.36);
Query OK, 1 row affected (0.21 sec)
Exiba todos os registros da tabela usando a instrução select:
mysql> select *from DemoTable;
Saída
+-------------+
| Amount |
+-------------+
| 84848757.60 |
| 95868685.50 |
| 4242342.36 |
+-------------+
3 rows in set (0.00 sec)
A seguir está a consulta para definir o separador no MySQL:
mysql> select format(Amount,2) from DemoTable;
Saída
+------------------+
| format(Amount,2) |
+------------------+
| 84,848,757.60 |
| 95,868,685.50 |
| 4,242,342.36 |
+------------------+
3 rows in set (0.00 sec)