10. Modify

We already know how to query, filter, order, add new data and delete. The only thing left is to change existing data. The reserved word for this task is UPDATE.

UPDATE [tabla] SET [columna] = [nuevo valor], [columna] = [nuevo valor], ... WHERE [condicion];

Let's change the customer with Id 10, named Eduardo, to indicate that he is now at a small company called Facebook.

UPDATE Customer SET Company = 'Facebook' WHERE CustomerId = 10;

Did he move to Valencia? We change the columns that are needed.

UPDATE Customer SET City = 'Valencia', State = 'Comunidad Valenciana', Country = 'Spain' WHERE CustomerId = 10;

Our boss wants to change all the countries that say USA to EEUU.

UPDATE Customer SET Country = 'EEUU' WHERE Country = 'USA';
Activity 1

We go back to using the Track table (song).

  • Raise the price of all the songs from 0.99 to 2.99.
  • Raise the price of all the songs from 1.99 to 4.99.
  • Change the Composer (Composer) to Sara for TrackId number 2000.
  • Change the Composer (Composer) to clasico for all the songs that start with the name Concerto.

Solutions

Building SPAs with Django and HTML Over the Wire: Learn to build real-time single page applications with Python

Building SPAs with Django and HTML Over the Wire: Learn to build real-time single page applications with Python

The HTML over WebSockets approach simplifies single-page application (SPA) development and lets you bypass learning a JavaScript rendering framework such as React, Vue, or Angular, moving the logic to Python. This web application development book provides you with all the Django tools you need to simplify your developments with real-time results.

Buy the book

Help me keep writing

Every coffee gives me a push toward the next article.

Comments

There are no comments yet.