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 trial

Databases

Björn Norén
Björn Norén
9,569 Points

Mysql 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.

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Just 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.

1 Answer

Henrik Hansen
Henrik Hansen
23,176 Points

Yes, 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
Björn Norén
9,569 Points

Wow, thanks :) That was very easy to understand!