简体   繁体   中英

MySQL DECIMAL data type

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.

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM