Spring Deals - hours only!Up to 70% off on all courses and bundles.-Close
Introduction
Inserting data
Modifying data
11. Modify data—arithmetic operations
Deleting data
CRUD

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 their current age—for whatever reason.

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

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 the price of Kosovo Bread be 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 = N'starter';