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. Link to comment https://forums.phpfreaks.com/topic/206313-best-way-to-store-prices-in-database/ 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 Link to comment https://forums.phpfreaks.com/topic/206313-best-way-to-store-prices-in-database/#findComment-1079287 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. Link to comment https://forums.phpfreaks.com/topic/206313-best-way-to-store-prices-in-database/#findComment-1079290 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.