SQL Update Statement, SQL Tutorial, Global Guide Line Technology.
Forum | Blog |


Basic SQL Guide.           
SQL Introduction.               
 What is Table?                  
 SQL Create Table.            
 SQL Insert Statement.      
 SQL Select Keyword.        
 SQL Order by clause.        
 SQL Count Statement.      
 SQL Group By Clause.      
 SQL Having Clause.          
 SQL Alias Tables.             
 SQL Join Tables.              
 SQL Outer Join.               
 SQL Update Statement.
 SQL Delete Statement.    
 SQL Distinct Keyword.      
 SQL Where Keyword.       
 SQL And Or Keyword.      
 SQL In Keyword.              
 SQL Between Keyword.   
 SQL Like Keyword.          
 SQL Functions.                
 SQL Concatenate.           
 SQL Substrings.               
 SQL Trim Function.         
 SQL Constraints.              
 SQL Primary Key.            
 SQL Foreign Key.            
 SQL Create Views.           
 SQL Create Index.           
 SQL Alter Table.             
 SQL Drop Table.             
 SQL Truncate Table.      
 SQL Summary.                

SQL Tutorial >> SQL Update Statement.

     Back             Next     

Once there's data in the table, we might find that there is a need to modify the data. To do so, here in SQL Tutorial we can use the UPDATE command to do so. The syntax for SQL Update Statement is as under

Syntax for SQL Update Statement

UPDATE "table_name"
SET "column_1" = [new value]
WHERE {condition}

For example, say we currently have a table as below and we want to update it.:
 Table Employees_Salary

FirstName Month Salary
Austin February 1100$
Creston February 1100$
Kate February 1100$
Angela February 1000$
Bobbi February 1200$

and now suppose we need to change the salary for Angela from 1000$ to 1200$ , for that particular entry needs to be updated. To do so, we use the following SQL Update Statement

Example of SQL Update Statement

UPDATE Employees_Salary
SET Salary = 1200
WHERE FirstName = "Angela"

The resulting table would look like

Result of SQL Update Statement Example:

FirstName Month Salary
Austin February 1100$
Creston February 1100$
Kate February 1100$
Angela February 1200$
Bobbi February 1200$

In this case, there is only one row that satisfies the condition in the SQL WHERE clause. If there are multiple rows that satisfy the condition, all of them will be modified.

It is also possible to UPDATE multiple columns at the same time. The syntax for update multiple columns in this case would look like the following, and this SQL Tutorial section will cover all the needs of SQL update statement clause.

UPDATE "table_name"
SET column_1 = [value1], column_2 = [value2]
WHERE {condition}

     Back             Next     

[ About ] [ Contact ] [ Home ]
[ Links ] [ Site Map ] [ Services ] [ Privacy ]

Copyright 2005 -  2022 www.globalguideline.com All rights reserved. (Best viewed in IE 6.0+ or Firefox 2.0+ at 1024 * 768 or higher) 319 visitors are online now