pcplans.com § Help and Support How to: using SQL to Update Records  

How to: using SQL to Update Records

Article ID:9245
Last Review:Thursday, January 08, 2009
Revision:3.0

INTRODUCTION

How to: using SQL to Update Records

symptomsIMPORTANT

How to: using SQL to Update Records


IMPORTANT

How to: using SQL to Update Records
The update statement is used to update or change records in a table.
Records may match a specified criteria.
back to the top

How to: using SQL to Update Records


Updating Records The update statement is used to update or change records that match a specified criteria. This is accomplished by carefully constructing a where clause.



update "tablename"
set "columnname" = 
    "newvalue"
 [,"nextcolumn" = 
   "newvalue2"...]
where "columnname" 
  OPERATOR "value" 
 [and|or "column" 
  OPERATOR "value"];

[ ] = optional


[The above example was line wrapped for better viewing on this page.]

Examples:

update phone_book


  set area_code = 623
  where prefix = 979;

update phone_book
  set last_name = 'Smith', prefix=555, suffix=9292
  where last_name = 'Jones';

update employee
  set age = age+1
  where first_name='Mary' and last_name='Williams';


Update statement exercises After each update, issue a select statement to verify your changes. Jonie Weber just got married to Bob Williams. She has requested that
her last name be updated to Weber-Williams.
Dirk Smith's birthday is today, add 1 to his age.
All secretaries are now called "Administrative Assistant". Update all titles accordingly.
Everyone that's making under 30000 are to receive a 3500 a year raise.
Everyone that's making over 33500 are to receive a 4500 a year raise.
All "Programmer II" titles are now promoted to "Programmer III".
All "Programmer" titles are now promoted to "Programmer II".
Create at least 5 of your own update statements and submit them.







  • NOTE: How to: using SQL to Update Records
  • back to the top




    Last Reviewed:1/8/2009
    Keywords: kbHow kbhowtoHow kbHOWTOHow #9245 kbAudITProHow



        Contact

       ©1999-2008 Support at pcplans.com