Reputation: 3641
I have php file that is pulling data from a server, it is correctly parsed , anyways
this is a sample data:
"headerTotalValue":"2,338,848.0000000000" , "headerTotalVolume":"279,000.0000000000"
Now in my script the values are correctly display as is but whenever I am inserting them in my DB it only stores as 2
and 279
but I want them as 2,338,848
and 279,000
The column is Value INT(12)
and Volume INT(12)
Any thoughts what's wrong happening here.
Upvotes: 0
Views: 64
Reputation: 634
You can't use ',' and '.' in an INT
field.
Integer cannot take floating-point numbers, only whole numbers.
Reformat your data to read like 2338848
and 279000
and use INT
.
If you need the digits after the comma, change your field to DOUBLE
and use numbers like 2338848.0
and 279000.0
.
Further reading about data types:
EDIT: As Mani has commented, here the direct link to the floating-point section of the MySQL Manual: https://dev.mysql.com/doc/refman/5.5/en/floating-point-types.html
Upvotes: 1
Reputation: 3332
Your column definition should be using something like decimal(17, 10)
instead of int(12)
Read here from more info.
Upvotes: 0
Reputation: 888
1.First thing you posting Floting point value but database column as INT
2.Second you use comma(,) its CHAR
so you can avoid coma or use VARCHAR
in DB
Upvotes: 1