Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialBjörn Norén
9,569 PointsMysql Addition & Subtraction
Hi! I'm working with a fictive Music Shop were the shop needs to order instruments from a deliver company when they are out of guitars, pianos etc. And I realized I really don't know how to use addition ( for ordering ) and subtraction ( when a instrument is being sold ).
I guess I need a column for quantity? Like:
Instrument_ID : D1445 Quantity : 26 ( for example )
Am I on the right track? Could someone share a brief explanation on how I should move on? Thank you very much, sorry for my bad english.
1 Answer
Henrik Hansen
23,176 PointsYes, that is right. You can use the current value in a field in your SQL command.
UPDATE table_name
SET quantity = quantity - 1
WHERE id = 'D1445'
Björn Norén
9,569 PointsWow, thanks :) That was very easy to understand!
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherJust a note: In that entire block of text I only saw one spelling error and one misplaced comma :) Trust me when I tell you that there are native English speakers that don't write as well as you do.