The UPDATE statement

 

Sometimes, a database application may need to change data that already exists in the data source with which it is interacting. This can be accomplished using an UPDATE query. The general form of this statement is:

 

UPDATE tablename
SET column=value
WHERE condition

 

UPDATE is especially useful when you want to change many records at once, or when the records that you want to change are in multiple tables.

 

You can change several fields at the same time. The following example increases the OrderAmount values by 10 percent and the Freight values by 3 percent for shippers in the United Kingdom:

 

UPDATE Orders
SET OrderAmount = OrderAmount * 1.1, Freight = Freight * 1.03
WHERE ShipCountry = 'UK'

 

UPDATE doesn't generate a result set. If you want to know which records will be changed, first examine the results of a select query that uses the same criteria, and then run the update query.

 

In the ODBC, the UPDATE statement must always contain a WHERE clause unless it is a positioned UPDATE statement.