?
Solved

MySql keeps rounding off my prices

Posted on 2010-01-01
7
Medium Priority
?
350 Views
Last Modified: 2013-12-12
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
0
Comment
Question by:Eaddy Barnes
7 Comments
 
LVL 43

Expert Comment

by:pcelba
ID: 26157643
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).
0
 
LVL 12

Expert Comment

by:jet-black
ID: 26157684
Use FLOAT type for that column.
0
 
LVL 12

Expert Comment

by:jet-black
ID: 26157687
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 83

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 26157691
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

0
 
LVL 12

Expert Comment

by:jet-black
ID: 26157693
0
 
LVL 11

Author Closing Comment

by:Eaddy Barnes
ID: 31671763
thanks
0
 
LVL 83

Expert Comment

by:leakim971
ID: 26158345
You're welcome! Thanks for the points and happy new year!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating a Cordova application which allow user to save to/load from his Dropbox account the application database.
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month14 days, 11 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question