Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Inserting data
Modifying data
9. Modify multiple columns
Deleting data
CRUD

Instruction

Right! You can also modify values for multiple columns at the same time.

When you want to modify the name and age of the user with ID 1, use the command:

UPDATE user 
SET
  name = 'Elizabeth',
  age = 17 
WHERE id = 1;

This command sets the name to Elizabeth and the age to 17 for the user with ID 1.

Exercise

Spring Rolls now sell like crazy, and nobody's interested in Prawn Salad (ID 1) anymore. We need to change its name to something more exotic – let's try Green Sea Dragon.

In addition to that, set the price at 10 to encourage customers to try the dish.

Stuck? Here's a hint!

Type:

UPDATE dish 
SET
  name = 'Green Sea Dragon',
  price = 10 
WHERE id = 1;