Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
How to place a thousand separator in MySQL records?
Use the FORMAT() method for this. Let us first create a table −
mysql> create table DemoTable -> ( -> Amount DECIMAL(10,2) -> ); Query OK, 0 rows affected (0.45 sec)
Insert some records in the table using insert command −
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)
Display all records from the table using select statement −
mysql> select *from DemoTable;
Output
+-------------+ | Amount | +-------------+ | 84848757.60 | | 95868685.50 | | 4242342.36 | +-------------+ 3 rows in set (0.00 sec)
Following is the query to set separator in MySQL −
mysql> select format(Amount,2) from DemoTable;
Output
+------------------+ | format(Amount,2) | +------------------+ | 84,848,757.60 | | 95,868,685.50 | | 4,242,342.36 | +------------------+ 3 rows in set (0.00 sec)
Advertisements
