Basics

  1. Introduction
  2. Database Structure

    Commands

  3. Create
  4. Select
  5. Insert
  6. Update
  7. Delete
  8. Drop

    Operations

  9. Joining Tables

    Appendices

  10. Terms
  11. Credits

SQL Update Command

This command is used to make changes to records in tables. Syntax:

update tablename
set columnname = newvalue [,columnxname = newvaluex...]
where columnname OPERATOR value [and|or columnnamex OPERATOR valuex];

The OPERATOR is one of the conditions listed on the Select Command page.

OPERATORs include:

  • = - Equal
  • < - Less than
  • > - Greater than
  • <= - Less than or equal
  • >= - Greater than or equal
  • <> - Not equal
  • LIKE - Allows the wildcard operator, %, to be used to select items that are a partial match. An example is:

    select city, state from towntable where state like 'north%'

    This allows selection of all towns in states that begin with the word "north" allowing states like North Dakota and North Carolina to be selected.

Example

update citylist
set population = population+1
where name = 'Argos' and
state = 'Indiana';