Lesson 5 | Using UPDATE |
Objective | Modify existing records using the UPDATE statement. |
Modify existing Records using the UPDATE statement
Data in the VirtualBookShelf.com 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:
SET:
allows you to update single or multiple columns
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:
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.