• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 353
  • Last Modified:

MySql keeps rounding off my prices

whenever i enter a number into a field  such as 210.50 it will show up in the field as 211!
regardless of what i put in.. it will round the number off to its nearest whole number.
and needless to say the cents are important when it comes to the price field
Eaddy Barnes
Eaddy Barnes
1 Solution
What is the data type of the table column? This behavior is typical for integer or numeric without decimal places. Also the regional settings could affect decimal point interpretation (comma is used somewhere).
Use FLOAT type for that column.
Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

Hello greeneel,

Assuming you column is an INT and must be NOT NULL :

Type : http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html
ALTER TABLE ...  CHANGE: http://dev.mysql.com/doc/refman/5.0/fr/alter-table.html

ALTER TABLE database_name.table_name CHANGE old_field_name new_field_name DECIMAL(10,2) NOT NULL DEFAULT '0';

Open in new window

Eaddy BarnesITAuthor Commented:
You're welcome! Thanks for the points and happy new year!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now