- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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 do I format a number as decimal to store it in MySQL?
You do not need to format a number in MySQL, for this use DECIMAL data type. Let us first create a table −
mysql> create table DemoTable1330 -> ( -> Amount DECIMAL(10,2) -> ); Query OK, 0 rows affected (0.85 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1330 values(10944.7893); Query OK, 1 row affected, 1 warning (0.13 sec) mysql> insert into DemoTable1330 values(9848.44); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1330 values(8009.90); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1330 values(1000.99); Query OK, 1 row affected (0.13 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1330;
This will produce the following output −
+----------+ | Amount | +----------+ | 10944.79 | | 9848.44 | | 8009.90 | | 1000.99 | +----------+ 4 rows in set (0.00 sec)
- Related Articles
- How to store decimal in MySQL?
- How to format number to 2 decimal places in MySQL?
- How to format number with “.” as thousand separators, and “,” as decimal separator?
- How do I re-format datetime in MySQL?
- How do I format the axis number format to thousands with a comma in Matplotlib?
- How can I store ‘0000-00-00’ as a date in MySQL?
- How do I stop a MySQL decimal field from being rounded?
- Parse and format a number to decimal in Java
- How to store data in MySQL as JSON?
- How to store the PayPal decimal amount in the MySQL database?
- What should I do? Select int as currency or convert int to currency format in MySql?
- How is it possible to store date such as February 30 in a MySQL date column?
- How do I update the decimal column to allow more digits in MySQL?
- Format amount values for thousands number with two decimal places in MySQL?
- How do I console.log JavaScript variables as it relates to DOM?

Advertisements