Home page
or browse popular tags

Sign up for the free email newsletter for new tips, tutorials and more. Enter your email address below, and then click the button.

Privacy Policy

RSS Twitter

SQL: UPDATE Statement


In daily use, a database is a constantly changing store of data. The SQL commands which are used to modify data that is already in the database are the Update and the Delete commands.The Update statement allows you to update a single record or multiple records in a table.

The syntax for the Update statement is as follows:

UPDATE table_name
SET column_name = expression
WHERE conditions

Example #1

UPDATE AntiqueOwners
SET Address = '77, Lincoln st.'
WHERE OwnerFirstName= 'Jane' and OwnerLastName = 'Akins'

The Update statement can be used in updating a single field in a table.This statement would update address of Jane Akins in the AntiqueOwners table to 77, Lincoln st..

Note: The Update doesn't generate a result set. If you want to know which records will be modified, first run a Select query that uses the same criteria. If the results are satisfactory, then run the update query.

Example #2

UPDATE AntiqueOwners
SET Address = '77, Lincoln st.', City = 'Kirkland', State = 'Washington'
WHERE OwnerFirstName='Jane' And OwnerLastName='Akins'

The Update statement can also be used to update more than one field in a table. The preceding example changes the address, city and state.


Add To: Add to dzone dzone | Digg this digg | Add to del.icio.us del.icio.us | Stumble it stumbleupon

  • Comments

Copyright © 2005-2023             www.WebCheatSheet.com All Rights Reserved.