Skip to content

UPDATE Operations

The UPDATE query is used at National 5 to edit the value(s) stored in one field of a database table.

For example:

1
2
3
UPDATE Product 
SET price = price * 1.10 
WHERE productName LIKE D*; 

This query will increase the price of every product, with a name that begins with the letter D, by 10%.

For Higher, candidates are required to use a single query to change the values stored in more than one field of a database query.

The general syntax of this UPDATE query is:

1
2
3
UPDATE tableName 
SET field1 TO expression... , field2 TO expression ...
WHERE criteria ... ; 

Note

Each expression used in the SET clause can be a specific value or an expression (which can, if required, use arithmetic operators). The WHERE clause is optional.