The Wayback Machine - https://web.archive.org/web/20071011015536/http://sqlcourse.com:80/update.html


Free Newsletters:
DatabaseJournal
DBANews
 

SQLCourse
Interactive Online SQL Training
HOME News MS SQL Oracle DB2 Access MySQL PHP SQL Etc Scripts Links Forums DBA Talk
internet.com
SQL Courses
1 What is SQL?
2 Table basics
3 Selecting data
4 Creating tables
5 Inserting into a table
6 Updating records
7 Deleting records
8 Drop a table
9 Advanced Queries
10 Standalone SQL interpreter
11 Advertise on SQLCourse.com
12 Database Links
13 Technology Jobs




internet.commerce
Partner With Us
Franchise Directory
Logo Design
PDA Phones & Cases
Giveaways
Affiliate Programs
Mortgage Refinance
Holiday Gift Ideas
Mp3 Player Reviews
Domains for Business
Data Center Solutions
Promotional Pens
Online Education
Promotional Products
Promote Your Website

internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Whitepaper: ProCurve ProActive Defense Empowers Your Business with More Security and Less Complexity. Make your network immune to threats, control access and usage, & protect data & integrity.
Access FREE HP ProCurve Tools:
Whitepaper:
ProCurve ProActive Defense Empowers Your Business with More Security and Less Complexity

Whitepaper:
Extending the Enterprise Network Through Mobility

Whitepaper:
Convergence--Preparing the Enterprise Network

Video:
ProCurve Networking by HP

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 Web 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.

  1. Jonie Weber just got married to Bob Williams. She has requested that her last name be updated to Weber-Williams.
  2. Dirk Smith's birthday is today, add 1 to his age.
  3. All secretaries are now called "Administrative Assistant". Update all titles accordingly.
  4. Everyone that's making under 30000 are to receive a 3500 a year raise.
  5. Everyone that's making over 33500 are to receive a 4500 a year raise.
  6. All "Programmer II" titles are now promoted to "Programmer III".
  7. All "Programmer" titles are now promoted to "Programmer II".

Create at least 5 of your own update statements and submit them.

Answers to exercises

SQL Interpreter


SQL Course Curriculum
<<previous 1 2 3 4 5 6 7 8 9  next>>


Solutions


JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info