- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to make numbers 'human readable' in MySQL?
To make numbers ‘human readable’ i.e. including separators, you need to use format(). Let us first create a table −
mysql> create table DemoTable859(Number bigint); Query OK, 0 rows affected (1.54 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable859 values(747464646473737); Query OK, 1 row affected (0.45 sec) mysql> insert into DemoTable859 values(3836365366464); Query OK, 1 row affected (0.71 sec) mysql> insert into DemoTable859 values(8376437647433); Query OK, 1 row affected (0.46 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable859;
This will produce the following output −
+-----------------+ | Number | +-----------------+ | 747464646473737 | | 3836365366464 | | 8376437647433 | +-----------------+ 3 rows in set (0.00 sec)
Following is the query to make numbers 'human readable' in MySQL −
mysql> select format(Number, 0) AS HumanReadableFormat from DemoTable859;
This will produce the following output −
+---------------------+ | HumanReadableFormat | +---------------------+ | 747,464,646,473,737 | | 3,836,365,366,464 | | 8,376,437,647,433 | +---------------------+ 3 rows in set (0.00 sec)
Advertisements