Home DBMS SQL PL/SQL SQLite MongoDB Cassandra MySQL Oracle CouchDB Neo4j DB2 C Java Projects Interview Q
⇧ SCROLL TO TOP
SQL Update Statement
The SQL UPDATE statement is used to modify the data that is already in the database. The
condition in the WHERE clause decides that which row is to be updated.
Syntax
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
Sample Table
ADVERTISEMENT
ADVERTISEMENT
EMPLOYEE
EMP_ID EMP_NAME CITY SALARY AGE
1 Angelina Chicago 200000 30
2 Robert Austin 300000 26
3 Christian Denver 100000 42
4 Kristen Washington 500000 29
5 Russell Los angels 200000 36
6 Marry Canada 600000 48
Updating single record
Update the column EMP_NAME and set the value to 'Emma' in the row where SALARY is
500000.
Syntax
UPDATE table_name
SET column_name = value
WHERE condition;
Query
UPDATE EMPLOYEE
SET EMP_NAME = 'Emma'
WHERE SALARY = 500000;
Output: After executing this query, the EMPLOYEE table will look like:
EMP_ID EMP_NAME CITY SALARY AGE
1 Angelina Chicago 200000 30
2 Robert Austin 300000 26
3 Christian Denver 100000 42
4 Emma Washington 500000 29
5 Russell Los angels 200000 36
6 Marry Canada 600000 48
Updating multiple records
If you want to update multiple columns, you should separate each field assigned with a comma.
In the EMPLOYEE table, update the column EMP_NAME to 'Kevin' and CITY to 'Boston' where
EMP_ID is 5.
Syntax
UPDATE table_name
SET column_name = value1, column_name2 = value2
WHERE condition;
Query
UPDATE EMPLOYEE
SET EMP_NAME = 'Kevin', City = 'Boston'
WHERE EMP_ID = 5;
Output
EMP_ID EMP_NAME CITY SALARY AGE
1 Angelina Chicago 200000 30
2 Robert Austin 300000 26
3 Christian Denver 100000 42
4 Kristen Washington 500000 29
5 Kevin Boston 200000 36
6 Marry Canada 600000 48
Without use of WHERE clause
If you want to update all row from a table, then you don't need to use the WHERE clause. In the
EMPLOYEE table, update the column EMP_NAME as 'Harry'.
Syntax
UPDATE table_name
SET column_name = value1;
Query
UPDATE EMPLOYEE
SET EMP_NAME = 'Harry';
Output
Download now
Trade responsibly.
62% of retail CFD accounts lose money
EMP_ID EMP_NAME CITY SALARY AGE
1 Harry Chicago 200000 30
2 Harry Austin 300000 26
3 Harry Denver 100000 42
4 Harry Washington 500000 29
5 Harry Los angels 200000 36
6 Harry Canada 600000 48
Ad
AACSB-accredited MBA
University of Adelaide Apply Now
← Prev Next →
For Videos Join Our Youtube Channel: Join Now
Feedback
Send your Feedback to feedback@javatpoint.com
Help Others, Please Share
Sync SharePoint to
SQL Tables
Open
Learn Latest Tutorials
Splunk SPSS Swagger Transact-SQL Tumblr
ReactJS Regex Reinforcement R Programming RxJS
Learning
React Native Python Design Python Pillow Python Turtle Keras
Patterns
Preparation
Aptitude Reasoning Verbal Ability Interview Company
Questions Questions
Trending Technologies
Artificial AWS Selenium Cloud Computing Hadoop
Intelligence
Data Science Angular 7 Blockchain Git Tutorial
Tutorial Tutorial Tutorial Git
Data Science Angular 7 Blockchain
ReactJS
Machine DevOps
Learning Tutorial
Tutorial DevOps
Machine
Learning
B.Tech / MCA
DBMS Data DAA tutorial Operating Computer
tutorial Structures DAA
System Network
DBMS
tutorial Operating
tutorial
Data Structures System Computer
Network
Compiler Computer Discrete Ethical Computer
Design tutorial Organization Mathematics Hacking Graphics
Compiler Design
and Tutorial Ethical Hacking
Tutorial
Architecture Discrete Computer
Computer Mathematics Graphics
Organization
Software html tutorial Cyber Automata C Language
Engineering Web Technology
Security Tutorial tutorial
Software
tutorial Automata C Programming
Engineering Cyber Security
C++ tutorial Java tutorial .Net Python List of
Framework tutorial Programs
C++ Java
tutorial Python Programs
.Net
Control Data Mining Data
Systems Tutorial Warehouse
tutorial Data Mining
Tutorial
Control System Data Warehouse