July 10, 2007
Float can't update
Uncategorized
1 Comment
Comersus Version: 603
Database type: Other
Frequency: Permanent issue
I want to update my prices, and there are thousands! So I tried:-
UPDATE products SET price=17.99
WHERE price=17.9
But it didn't work.
I found online that float numbers are not stored exactly as they seem.
Would it affect anything if the price was changed from float to decimal?
I can't experiment, as I am getting orders in all the time.
One Comment
Hi,
You can check the value of price field with a simple
SELECT * FROM products WHERE idProduct=xx
Where xx is the idproduct of the item that should have 17.9
You can also use round function to get only 2 decimals and then update the price
You can try:
UPDATE products SET price=17.99 WHERE round(price,2)=17.90
Make a backup of your database before the update.
[Reply]