Modifying data
1. Modify data

Instruction

Great! Now that you know how to add data to the database, it's time to learn how to modify data.

If you want to change the name of the user with id 7, you can use the command:

UPDATE user SET name = 'Elizabeth' WHERE id = 7;

Here, user is the modified table, name is the modified column and 'Elizabeth' is the new value of the column. The WHERE condition tells the database which rows should be modified and it can be any condition you'd write in a SELECT command. (Remember that can always go to the SQL Queries course for more information).

After you run the command, the name for the user with id 7 will be set to Elizabeth. Piece of cake!

Exercise

The owners of the restaurant complain that the item with the id 2 sells poorly. This might be because Spring Scrolls don't really sound like something particularly edible.

Correct the name and change it to Spring Rolls.

Stuck? Here's a hint!

Type

UPDATE dish SET name = 'Spring Rolls' 
WHERE id = 2;