say p.products_price equals 1
why does:
UPDATE products p SET p.products_price = (1 + p.products_price) WHERE p.products_id = 8
make p.products_price equals 3?
It is adding 1 to the price and then doing it all over again? I am trying to do something a little more complicated but when it didn't work I broke it down to the simplest thing ever. Can I make some kind of temporary value here and calculate the new price and then set it to that?
Please help I am raging, Thanks.
MySQL client version: 4.1.22
edit: the column is decimal type, i tried the same update on an int column with the same result.
edit: this is not running in code so there is no chance of the code calling the same update twice
UPDATE products
SET products_price = (1 + products_price)
WHERE products_id = 8
works like it should (removed table alias 'p')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With