开发者

Entering A price

开发者 https://www.devze.com 2023-04-01 05:54 出处:网络
What would be the best way to set my SQL field for a value such as $34,000. My SQL is: price DECIMAL(4,2) and it seems I can only output 34.00.How could I also make it s开发者_C百科how with a , not a

What would be the best way to set my SQL field for a value such as $34,000.

My SQL is: price DECIMAL(4,2) and it seems I can only output 34.00. How could I also make it s开发者_C百科how with a , not a . (could possibly be to due my cms stripping data)


For $34,000 you need DECIMAL(7,2), five digits before the decimal point, two after.

And think about if you really need to be so restrictive. Two decimals after the point makes sense, but you want to err on the safe side with the total number, otherwise you cannot store say, $1,000,000, in your database.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号