storing money amounts in mysql

后端 未结 7 671
野趣味
野趣味 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:11

    Does it really matter if it stores is as 3.5, 3.50 or even 3.500?

    What is really important is how it is displayed after it is retrieved from the db.

    Or am I missing something here?

    Also don't use a float, use a decimal. Float has all sorts of rounding issue and isn't very big.

提交回复
热议问题