bobby317 Posted June 30, 2010 Share Posted June 30, 2010 What is the correct way to store a price in a mysql database. Here is an example: 15.49. Also if you could explain why so I can learn or point me to some resources. THanks. Quote Link to comment Share on other sites More sharing options...
litebearer Posted June 30, 2010 Share Posted June 30, 2010 type would be decimal 2, unless your pricing includes fractions of a cent then you might use more decimals or a float Quote Link to comment Share on other sites More sharing options...
Psycho Posted June 30, 2010 Share Posted June 30, 2010 From the manual: http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html (emphasis added) The DECIMAL and NUMERIC data types are used to store exact numeric data values. In MySQL, NUMERIC is implemented as DECIMAL. These types are used to store values for which it is important to preserve exact precision, for example with monetary data. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.