Fix MySQL Float Data Field Not Accepting Every Float Number



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: 2019-08-22T08:40:52+05:30

165 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements