DML – UPDATE

 

Use the UPDATE statement to change data values in one or more columns, usually based on specific criteria.

 

 

Exercise:  Assign suppliers from London and Manchester in the MySuppliers table to the UK region.  Check the the relevant rows in the table (that is, run SELECT queries with the same criteria) before and after running this update query:

 

UPDATE MySuppliers

SET Region = "UK"

WHERE City IN ("London", "Manchester");

 

 

Exercise:  Where no region has been entered in the MySuppliers table, change the value to “Unassigned”.  Check the table before and after running the query:

 

UPDATE MySuppliers

SET Region = "Unassigned"

WHERE Region is null;

 

 

Syntax

 

UPDATE tablename

SET col1 = value1, col2 = value2, ...

WHERE criteria