Here is an easy question for someone. When using mysql, how do you increase or decrease the number in a particular cell by a specified amount with a single query. For example i have a product table with 5 x product a. I sell 1 item and i want to update the field. I want to do it with one query, not get the number add to it and then update(I know how to do that) Thanks Andrew
+1
A:
update products set amount = amount + 1 where productId = 12345
If you are using prepared statements you can replace the amount to add as well as the product id with placeholders
Steve De Caux
2009-11-27 09:41:59
Early bird gets the worm.
andrew
2009-11-27 09:59:26