MySQL Add/subtract Quantities?Jul 17, 2005
Two mySQL Questions:
1.) how to numerically increase or decrease the value of a mySQL column
2.) what is the best column structure (e.g. "varchar" or "char" etc.)
for speediest increasing/decreasing
Here is the idea:
I sell fruit. I start with 100 apples, 100 bananas, and 100 grapes.
Visitor purchases 8 apples so now I have 92 of them left. What is the
exact mysql query statement that I would use (the following is wrong,
but gives idea what I'm trying to do):
mysql_query("update fruit_table set quantity_left = 92 where fruit =
Also, what would be the best table structure for the quantity part. Is
this the best?
CREATE TABLE fruit_table (
fruit tinytext NOT NULL,
quantity_left int(3) unsigned zerofill NOT NULL default ༼'