Continually Improving.... let us know how support@devdiamond.net Sign in | Sign up
home articles news blog forum  

 
 


 
Skip Navigation LinksHome > Article > SQL Basics :: Update Statement
SQL Basics :: Update Statement
Abstract :
The Update Statement is very useful, you can use The Update Statement to update records on your database.

Views : 5439
Published : Monday, January 21, 2002
By
HyperLink

Avarage Rating :
Page Page 1 of 1

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.


About Author

        Yasir Send Feedback
        Yasir is a .NET expert, with over 5 years experience in Microsoft Technologies, 8 years overall programming experience, he is the owner, founder & primary contributor of Minwar.com, and he also works as IT Director in the hospitality industry.