开发者

creating a table with DECIMAL(11,2) as variable keep getting 0.00

I am new to PHY MySQL and PHPmyadmin. Creating a table with and inserting decimals as the variable . The table is created but shows 0.00 as my number. my columns is configured as amount DECIMAL(11,2) NOT NULL,

I开发者_高级运维 insert into the table:

INSERT INTO  
`amount`(`amt_id`,`amount`)
VALUES
('1', '$625545.00'), 


Drop the $ sign in the value:

INSERT INTO amount(amt_id,amount) VALUES ('1', '625545.00');

Note: MS SQL has a money field that can allow such values, but not MySQL.


I can see that you're entering string value (by using "$") in the field with data type DECIMAL (which is one type of numeric field). First you need to remove "$" from the value. And since you've set DECIMAL of 11,2 then it would be any value with ".00" even after saving only 625545. So, any of below will work for you:

INSERT INTO amount(amt_id,amount) VALUES ('1', '625545.00');

OR

INSERT INTO amount(amt_id,amount) VALUES ('1', '625545');

Hope it'll help you.


You are entering a string:

This:

INSERT INTO amount(amt_id,amount) VALUES ('1', '$625545.00'),

is Equivalent to

 INSERT INTO amount(amt_id,amount) VALUES ('1', 'helloworld'),

If you want to enter data in a DECIMAL(11,2) field, be sure to enter something like 12345.22

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜