storing money amounts in mysql

后端 未结 7 595
野趣味
野趣味 2020-11-29 19:36

I want to store 3.50 into a mysql table. I have a float that I store it in, but it stores as 3.5, not 3.50. How can I get it to have the trailing zero?

相关标签:
7条回答
  • 2020-11-29 20:29

    It's not generally a good idea to store money as a float as rounding errors can occurr in calculations.

    Consider using DECIMAL(10,2) instead.

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