PC Magazine

  PC Tech

Handling Data with SQL

Introduction

The INSERT statement

The SELECT statement

Defining Selection Criteria

Comparisons and Logical Connectors

Nulls and Three-Valued Logic

The UPDATE statement

The DELETE statement



X10.com - The SuperSite for Home Automation!

NextCard Internet Visa - Apply Now

 
  Categories
Software

Related Stories
SQL: The Universal Database Language
-- 11/3/98

Next: The DELETE statement

Handling Data with SQL
The UPDATE statement

Continued from Nulls and Three-Valued Logic

The UPDATE statement lets you modify existing rows in a named table.

If, for example, we just found out that Indiana Jones had a grade level of 16 and a salary of $40,000.00, we could update the database (and eliminate those troublesome NULLs) with the following SQL statement:

UPDATE EMPLOYEES
SET GRADE = 16, SALARY = 40000
   WHERE FIRST_NAME = 'Indiana' AND LAST_NAME = 'Jones' ;

The above example illustrates a single-row update, but the UPDATE statement can operate on multiple rows. All rows that meet the conditions of the WHERE clause are updated. If, say, you wanted to move all the employees from the Boston office to a new office in New York, you could enter the following:

UPDATE EMPLOYEES
SET BRANCH_OFFICE = 'New York'
   WHERE BRANCH_OFFICE = 'Boston' ;

If you omitted the WHERE clause, all of the rows in the table would be updated with the branch office value of 'New York'.

The syntax diagram for the UPDATE statement as shown is as follows:

UPDATE table
SET column = value [ {, column = value } ]
   [ WHERE predicate [ { logical-connector predicate } ] ];

Next: The DELETE statement

Published as PC Tech Feature in the 11/17/98 issue of PC Magazine.

Elsewhere on ZDNet
Learn SQL Online -- ZD University
Business Software: Databases -- ZD Products

 
 SPONSORED LINKS
@Backup   Your Solid Online Backup Plan. Download Now.
Services   9c/MINUTE LONG DISTANCE, 5c/MINUTE ON SUNDAYS!
STORAGE   Quantum means non-stop business, 24 hours a day
Software   X10.com -- The SuperSite for Home Automation
Books   Bargain Books up to 90% off at barnesandnoble.com
 ZDNET FEATURED LINKS
Downloads   Check out the best new downloads in Reviewer's Raves
Bargains!   Shop the Basement for best buys on computer products
Free Help   Got computing questions? ZDHelp has all the answers!
 MAGAZINE OFFERS
Free Offer   Get a FREE SUBSCRIPTION to Inter@ctive Week

TOP
Copyright (c) 1998 Ziff-Davis Inc.