I want to insert/update decimal number to mysql. But everytime I did. It return the round number or truncate dot number. I tried change the datatype of lv_pay and lv_dis either to decimal
and double
but still the result.
MySQL
update settings_price_pay set lv_pay='3.2',lv_dis='0' where pset='1' and cate='161a5954c2e7713417906c523204a2be' and ltype='p_rhi'
PHPMyadmin
2
Answers
Got an answer, just for novice like me. Change the 'length/value' of the row (in my case) from
(11,0)
into(11,2)
. Found it accidentally.First:
The data type of those numeric fields should be
DECIMAL(12,2)
or something similar, declaring that you use a picture of S#########9.99. Sign, ten digits, point, two digits.Second:
Don’t put your numbers in
'quotes'
. If you do, MySQL first coerces them to IEEE 64-bit numbers, then to whatever datatype you have for your columns. Say this:Notice that MySQL ignores the numbers in parentheses in
DOUBLE(11,2)
and simply uses a 64-bit IEEE floating point number. (It honors those numbers when you declare aDECIMAL(12,2)
data type.)