I have field where i store my grand total to a mysql filed as total and its type set as decimal(10,2)
When my php form adds up and updates the query for 112381348.40
(i.e 112 million)
but when i fetch or view it on phpMyadmin, the value shows as 99999999.99
from my data type set, it has to be 10 digits
and 2 decimals
where as it is maximum updating as 8
and 2
.
Am i understanding wrong or what am i doing wrong.
I know i can increase it to decimal(13,2)
and then see it.
But i would like to know the reason, why 10,2
is not happening?
The specification for decimal(m, n)
takes two arguments. The first is the "precision" and the second is the "scale". More colloquially, the first is the number of digits in the number. The second is the number of digits to the right of the decimal point.
So, your specification of decimal(10, 2)
can store numbers like: 12,345,678.90 -- i.e., up to 99,999,999.99. And that is the maximum number.
If you want to store numbers larger than that, then use a larger precision for the number. For your number, you need at least decimal(11, 2)
, although I would suggest a larger precision so you don't encounter this problem in the future.
In setting a float or decimal field, the first int value is the total character count. The second is how many decimal places. So:
//decimal(10,2)
12345678.90
//decimal(13,2)
12345678901.23
//decimal(7,3)
1234.567
See?
You have 11 digits. The first number is the total digits. Try:
DECIMAL(11, 2)