|
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
|
|
TOP |
Copyright (c) 1998 Ziff-Davis Inc. |