Written by me@grafxflow
08 Nov, 2012
1
33,127
If you have a numerical value in a MySQL database table, that you want to UPDATE by adding a value to it, or subtracting a value from it. This can be done with a single MySQL query.
So for an example, I have a database with a product which has a quantity of 10 in stock, somebody has just bought 5 so I need to subtract that value from the database quantity.
UPDATE products_table SET quantity = quantity - 5 WHERE product_id = 21
Later in the shop admin you receive new stock and so need to UPDATE the product quantity by adding 5 new items to its current quantity of 5.
UPDATE products_table SET quantity = quantity + 5 WHERE product_id = 21
28 Nov, 2012
01 Aug, 2015
Darth Maul and Micro-Organisms: Inside George Lucas's Cancelled Star Wars Sequel Trilogy
How to Automatically Convert DVD Subtitles to SRT on Mac
The $4 Billion Divorce: Inside the Awkward, Painful Sale of Lucasfilm to Disney
The Rift That Broke the Whip: Inside Lucas, Spielberg, and Harrison Ford's 'Furious Rows' Over Indiana Jones
Breaking the Endless Loop: Why Star Wars Needs an Origin Story
Founder, Grafxflow
I am a Full-stack Developer who also started delving into the world of UX/UI Design a few years back. I blog and tweet to hopefully share a little bit of knowledge that can help others around the web. I build lighting-fast dynamic content engines with Laravel, Winter CMS and Tailwind CSS. Thanks for stopping by!
java tutorial
15 Aug 2013
Woah this website is excellent i prefer examining the articles you write. Keep up the great get the job done! You understand, lots of individuals need all-around because of this info, you could potentially assist them to drastically.