- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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)
- How to store decimal in MySQL?
- How to format number to 2 decimal places in MySQL?
- How do I re-format datetime in MySQL?
- How do I format the axis number format to thousands with a comma in Matplotlib?
- How do I stop a MySQL decimal field from being rounded?
- How to format number with “.” as thousand separators, and “,” as decimal separator?
- Parse and format a number to decimal in Java
- How to store data in MySQL as JSON?
- How can I store ‘0000-00-00’ as a date in MySQL?
- How is it possible to store date such as February 30 in a MySQL date column?
- What should I do? Select int as currency or convert int to currency format in MySql?
- How do I update the decimal column to allow more digits in MySQL?
- How to store the PayPal decimal amount in the MySQL database?
- How do I create a random four-digit number in MySQL?