Originally Posted by
Dasher
Assuming that quantity is actual quantity of shirts available to sell, and the new SET value is quantity minus those actually sold, it should not be possible for the value to go negative unless the quantity value was inaccurate in the first place. Quantity should = stock on hand. (or at all stores or whatever)
Another option may be to use
LOCK TABLES
UPDATE inventory SET quantity = quantity - x WHERE item = 'shirt'
or
SELECT quantity ... and
UPDATE quantity SET = x ....
UNLOCK TABLES