MySQL DECIMAL data type

前端 未结 1 1594
闹比i
闹比i 2020-12-15 20:16

I have a column in MySQL with the type DECIMAL(2,1). When I insert the number 10 into the database it reads 9.9. I want it to read 10.0. Any ideas? Thanks.

相关标签:
1条回答
  • 2020-12-15 20:33

    DECIMAL(2,1) means (as the manual suggests) a decimal of 2 characters wide (in total!) and 1 decimal. If you want 10.0, you need DECIMAL(3,1) (three wide, one decimal).

    0 讨论(0)
提交回复
热议问题