Customer Login  .   Webmail Login  .   About Us  .   Contact Us
Go to: Articles List

SQL Basics Part 4 : Update Statement

The syntax for the Update statement is:

UPDATE TableName SET ColumnName1 = Value1 WHERE ColumnName2 = Value2

There are several things to note about this syntax example. If you do not supply a where clause the update will take effect on all records in the table. ColumnName1 and ColumnName2 can be the same column. Value1 and 2 should be enclosed in '' single quotes for strings and left out for integers.

Example:

UPDATE CustomerTable SET fname = 'Joe' WHERE lname = 'Doe'

This Update statement will set the fname equal to 'Joe' for all records that have the lname equal to 'Doe'. This poses a slight problem, how do you update records without damaging other ones. The answer to this problem is to have a certain column that does not change that you can use to change records from. Usually this field is an id number of some sort.

Shared Hosting
Rookie
Pro
Advanced
Dedicated Servers
BASE
BUSINESS
ENTERPRISE
Why Choose Brinkster?
Radical Support
Brinkster Datacenter
Brinkster Network
Corporate Social Responsibility
90 Day Money Back Guarantee
Unsurpassed Value
Client Testimonials
Additional Features
Antivirus
Merchant Account
E-Commerce
Live Chat Communicator
Free Firewall
Website Builder
Free Web Hosting
Support
General Support
Codebank Search
Forums
Articles
Click here for Brinkster Live Chat
Home   Domains   Shared Hosting   Dedicated Hosting   Partner   Support   About Us    Contact Us   Webmail
Copyright © Brinkster Communications Corporation All Rights Reserved. Privacy Policy & Legal