Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Modifying data
4. Modify data - arithmetic operations

Instruction

Nice! So far, we've only used fixed values when updating rows. We can, however, make the database do some math too. Take a look:

UPDATE user SET age = 10+age WHERE id = 5;

As a result of this query, the user with the id 5 will be older by 10 years compared to the current age - for whatever reason that would be.

Let's practice modifying data once again, this time using some arithmetic too!

Exercise

The restaurant owners think the starters are so delicious and popular that they should be much more expensive. Try multiplying their prices by 2.

Think in advance: what will be the price of Kosovo Bread after the change? Remember to check if your guess was correct!

Stuck? Here's a hint!

Type

UPDATE dish 
SET price = 2 * price 
WHERE type = 'starter';