MySQL float data field not accepting every float number? How to fix this?


To get fixed float data type, use DECIMAL(). This will fix the issue of unacceptance. Let us first create a table −

mysql> create table DemoTable(Amount DECIMAL(10,2));
Query OK, 0 rows affected (0.54 sec)

Insert some records in the table using insert command −

mysql> insert into DemoTable values(2194848.90);
Query OK, 1 row affected (0.65 sec)
mysql> insert into DemoTable values(90309393.79);
Query OK, 1 row affected (0.25 sec)
mysql> insert into DemoTable values(8999999.68);
Query OK, 1 row affected (0.30 sec)
mysql> insert into DemoTable values(90900000.99);
Query OK, 1 row affected (0.26 sec)

Display all records from the table using select statement −

mysql> select *from DemoTable;

This will produce the following output −

+-------------+
| Amount      |
+-------------+
| 2194848.90  |
| 90309393.79 |
| 8999999.68  |
| 90900000.99 |
+-------------+
4 rows in set (0.00 sec)

Updated on: 22-Aug-2019

127 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements