terlynn4 Posted August 4, 2007 Share Posted August 4, 2007 Let me start by saying that I'm a newbie to MySQL so this could be user error; please feel free to state the obvious. I am creating a table, and one of my variables is price, and I was using DECIMAL(4,2) as the type. When I entered my first item, I entered price as '159.99'. After I entered the item it said: Query OK, 1 row affected, 1 warning (0.00 sec). When I viewed the item I had just added, it displayed 99.99 as the value for price. I added a few more items to see what was happening, and it turned out that everything over 99.99 displayed 99.99 as the price, but everything less than that was correct. I double-checked that I had entered DECIMAL(4,2) instead of DECIMAL(2,2), but I had done it correctly. So I created a new table and used DOUBLE(4,2) as the type. It had the same results. All other types of variables work properly. Any idea what's going on or how to troubleshoot this? Thanks in advance. Edit: Sorry, I didn't read the forum posting rules until now. MySQL version is 5.0.26-12, and the following are my CREATE and INSERT codes: CREATE TABLE jewelry (name VARCHAR(100), type VARCHAR(50), material VARCHAR(20), price DOUBLE(4,2), description TEXT, in_stock ENUM('yes','no'), ID int(11) NOT NULL auto_increment, PRIMARY KEY (ID)); INSERT INTO jewelry (name, type, material, price, description, in_stock) VALUES ('Diamond Heart Ring', 'Rings', '14K Yellow Gold', '199.99', 'Beautiful, contemporary, heart-shaped ring with five round diamonds.', 'yes'); Quote Link to comment Share on other sites More sharing options...
terlynn4 Posted August 4, 2007 Author Share Posted August 4, 2007 A friend just clarified things for me. The (4,2) means the total length of the number is 4 and there are two places after the decimal. I previously thought the first number was the length of the left side of the decimal. Thanks anyway! 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.