i want to be able to store that amount into the database.INSERT INTO offers (offer_name,offer_type,value) VALUES (noobs,free,10.99)
Storing decimals into a database.
Moderator: General Moderators
Storing decimals into a database.
Hi, i would liek to know what type of column i would use if i wanted to store a money amount into my database. If i run a query like
- AKA Panama Jack
- Forum Regular
- Posts: 878
- Joined: Mon Nov 14, 2005 4:21 pm
You can use float, decimal or even text if you are using mysql.
You can use text if you are not going to be performing math of any type on the field inside a query.
Decimal works great because it doesn't return the value as an exponential like the float will. We have been using decimal for just about everything in our databases instead of float. Also, float has a resolution problem due to the way the value is stored. If you have a float it CAN be returned slightly off and not the exact number you stored.
You can use text if you are not going to be performing math of any type on the field inside a query.
Decimal works great because it doesn't return the value as an exponential like the float will. We have been using decimal for just about everything in our databases instead of float. Also, float has a resolution problem due to the way the value is stored. If you have a float it CAN be returned slightly off and not the exact number you stored.