I have a table structure like this:
Table Name: tbl_inventory_stock
id, INT, Primary Key
product_id, INT
store_id, INT
inventory_stok FLOAT
The value of a record that I want to update is like this:
id: 622
product_id: 2364
store_id: 6
inventory_stok: 2382980
Then I change the inventory_stok to 2382979 both directly from the table in phpmyadmin or executing syntax like this:
UPDATE `tbl_inventory_store` SET `inventory_stok` = '2382979' WHERE `tbl_inventory_store`.`id` = 622;
PHPMyAdmin displays the "0 row affected" and the inventory_stok value won’t change. It’s still 2382980.
Does anybody know why? I’ve been struggling for days, please help.
2
Answers
FLOAT is approximate datatype with low precision.
fiddle
Use more precise datatype. Either DOUBLE or DECIMAL (preferred).
Assuming there is a typo in the question table name float is just not a useful datatype amend to int using alter
then update
see https://dbfiddle.uk/6a-Gl7Uv
Can’t do this? then you cannot achieve what you set out to do..