Basic Queries  «Prev  Next»

Lesson 5 Using UPDATE
Objective Modify existing records using the UPDATE statement.

Modify existing Records using the UPDATE statement

Data in the Web site will change on a frequent basis. New customers will be added while others will become inactive or customer information will need to be changed if a customer moves. Book inventory information will change as the inventory fluctuates or when a book status changes from the regular price to sale price.
The UPDATE statement is used to modify rows in a table. A single UPDATE statement can modify all rows in a table or only selected rows.

Clauses used with UPDATE

Like the SELECT statement, the UPDATE statement uses clauses to specify columns and rows. These UPDATE clauses are:
  1. SET: allows you to update single or multiple columns
  2. WHERE: allows you to update specific rows just as with the SELECT statement

The following SlideShow describes how to construct the UPDATE statement syntax using the WHERE and SET clauses:
1) Update Statement 1 2) Update Statement 2 3) Update Statement 3 4) Update Statement 4 5) Update Statement 5 6) Update Statement 6 7) Update Statement 7 8) Update Statement 8 9) Update Statement 9
UPDATE Statement Syntax
SQL also lets you explicitly set values with a literal, such as Qty = 5. This might be used if you want to initialize columns in new rows to an initial value, or reset columns to a specific value. In the next lesson, the addition of rows to a table will be discussed.