a
 
SQLRef.Com 

            SqlRef.Com


SQL BASIC
DATA QUERY LANGUAGE
BASIC FUNCTION
AGGREGATE FUNCTION
DATA MANIPULATION LANGUAGE
DATA DEFINITION LANGUAGE
DATA CONTROL LANGUAGE
OTHERS

UPDATE

UPDATE <table> SET <column1> = <value1>, <column2> = <value2> [WHERE <conditions>]

Data stored in a table can be modified by using the UPDATE statement. Data can be modified one row at a time or in groups depending on the WHERE <conditions>.

Table1: Customers
CustID Name Address City Country PostCode Phone Fax
CUST001 Maria Anders Obere Str. 57 Berlin Germany 12209 030-0074321 030-0076545
CUST002 Ernst Handel Kirchgasse 6 Graz Austria 8010 7675-3425 7675-3426
CUST003 Helen Bennett Garden House Crowther Way Cowes UK PO31 7PJ (198) 555-8888 (198) 555-8889
CUST004 Paula Wilson 2817 Milton Dr. Albuquerque USA 87110 (505) 555-5939 (505) 555-5940
CUST005 Liu Wong 55 Grizzly Peak Rd. Butte USA 59801 (406) 555-5834 (406) 555-8083

The following SQL statement will update the Address of CUST003 from Garden House Crowther Way to Garden House.

UPDATE Customers SET Address = 'Garden House' WHERE CustID = 'CUST003'

Table2: Customers
CustID Name Address City Country PostCode Phone Fax
CUST001 Maria Anders Obere Str. 57 Berlin Germany 12209 030-0074321 030-0076545
CUST002 Ernst Handel Kirchgasse 6 Graz Austria 8010 7675-3425 7675-3426
CUST003 Helen Bennett Garden House Cowes UK PO31 7PJ (198) 555-8888 (198) 555-8889
CUST004 Paula Wilson 2817 Milton Dr. Albuquerque USA 87110 (505) 555-5939 (505) 555-5940
CUST005 Liu Wong 55 Grizzly Peak Rd. Butte USA 59801 (406) 555-5834 (406) 555-8083
.



 
| Freebies | Free Trial | Add to Bookmark | Search | Link to Us |
Copyright © 2006 SqlRef.com. All rights reserved.