Skip to content
  • SiteMap
  • Our Services
  • Frequently Asked Questions (FAQ)
  • Support
  • About Us

UpdateGadh

Update Your Skills.

  • Home
  • Projects
    •  Blockchain projects
    • Python Project
    • Data Science
    •  Ai projects
    • Machine Learning
    • PHP Project
    • React Projects
    • Java Project
    • SpringBoot
    • JSP Projects
    • Java Script Projects
    • Code Snippet
    • Free Projects
  • Tutorials
    • Ai
    • Machine Learning
    • Advance Python
    • Advance SQL
    • DBMS Tutorial
    • Data Analyst
    • Deep Learning Tutorial
    • Data Science
    • Nodejs Tutorial
  • Blog
  • Contact us
  • Toggle search form
SQL UPDATE Statement

SQL UPDATE Statement: A Complete Guide

Posted on February 15, 2025February 15, 2025 By Rishabh saini No Comments on SQL UPDATE Statement: A Complete Guide

SQL UPDATE Statement

SQL provides powerful commands to manipulate data within a database. Two important SQL commands, UPDATE and DELETE, allow users to modify existing records. The SQL UPDATE statement specifically helps in changing data within a table, targeting specific rows using the WHERE clause.

In this guide, we will explore how to use the SQL UPDATE statement effectively, along with syntax and examples. Let’s dive in!

Complete Python Course with Advance topics:-Click Here
SQL Tutorial :-Click Here

Understanding the SQL UPDATE Statement

The SQL UPDATE statement modifies existing records in a database table. You must use the WHERE clause to specify which rows need updating; otherwise, all rows will be modified, which may lead to unintended changes.

SQL UPDATE Syntax

UPDATE table_name  
SET column_name = new_value  
WHERE condition;

This syntax ensures that only specific rows meeting the given condition will be updated.

Example: Updating a Single Column

Assume that the following information is in a table called employees:

Employee_IDFirst_NameLast_NameEmail
101RohanKhannarohan.k@xyz.com
102SimranMehtasimran.m@xyz.com
103AryanSharmaaryan.s@xyz.com

Now, we update Email for the employee with Employee_ID = 103.

UPDATE employees  
SET Email = 'aryan.sh@xyz.com'  
WHERE Employee_ID = 103;

After executing this query, the updated table will be:

Employee_IDFirst_NameLast_NameEmail
101RohanKhannarohan.k@xyz.com
102SimranMehtasimran.m@xyz.com
103AryanSharmaaryan.sh@xyz.com

Updating Multiple Columns

If you want to modify multiple fields simultaneously, separate each assignment with a comma.

UPDATE employees  
SET Email = 'john.d@xyz.com', First_Name = 'John'  
WHERE Employee_ID = 103;

Updated Table:

Employee_IDFirst_NameLast_NameEmail
101RohanKhannarohan.k@xyz.com
102SimranMehtasimran.m@xyz.com
103JohnSharmajohn.d@xyz.com

MySQL Syntax for Updating a Table

The MySQL UPDATE statement follows a similar syntax:

UPDATE table_name  
SET column1 = new_value1, column2 = new_value2  
[WHERE condition];

SQL UPDATE with SELECT Query

We can use the SELECT statement inside an UPDATE query to dynamically update records based on another table.

SQL UPDATE with SELECT Syntax:

UPDATE target_table  
SET target_table.column_name = source_table.column_value  
WHERE EXISTS (  
    SELECT source_table.column_value  
    FROM source_table  
    WHERE source_table.join_column = target_table.join_column  
);

Alternatively, we can use INNER JOIN for updating records:

UPDATE target_table  
SET target_table.column1 = source_table.column1,  
    target_table.column2 = source_table.column2  
FROM target_table  
INNER JOIN source_table  
ON target_table.id = source_table.id;

Updating a Single Column in SQL

To update a specific column in a table:

UPDATE employees  
SET Employee_ID = 201  
WHERE First_Name = 'Amit';

This SQL UPDATE statement changes Employee_ID to 201 where the First_Name is Amit.

Updating Multiple Columns in SQL

If multiple column updates are required, use the following syntax:

UPDATE employees  
SET First_Name = 'Raj', Department = 'Finance'  
WHERE First_Name = 'Arun';

This will update First_Name to ‘Raj’ and Department to ‘Finance’ where First_Name was ‘Arun’.

Download New Real Time Projects :-Click here
Complete Advance AI topics:- CLICK HERE

Conclusion

The SQL UPDATE statement is a crucial command in database management, allowing for efficient data modification. By using the WHERE clause, SELECT statements, and JOINs, you can dynamically update data as needed while ensuring accuracy and consistency.

Mastering the UPDATE statement enhances your ability to manage databases effectively, making it an essential skill for database administrators and developers alike.

Stay tuned for more insightful SQL tutorials on UpdateGadh!


sql update statement with join
update query in sql server
sql update from select
update column value in sql
sql update from another table
delete command in sql
sql update multiple columns
update query in mysql
sql insert statement
sql delete statement

Post Views: 868
SQL Tutorial Tags:case statement, how to update statement in sql, how to use update statement in sql, pgsql update statement, sql server case statement, sql server update statement, sql statements, sql update statement, statement, switch statement, t-sql - update statement, update statement, update statement in sql, update statement sql, update statement syntax, update statement with join, update statements in t sql, update using case statement

Post navigation

Previous Post: Linear Search in Python
Next Post: Resume Builder Web Application Project in PHP Source Code

More Related Articles

SQL SELECT AS SQL SELECT AS – Column and Table Aliases in SQL SQL Tutorial
SQL JOIN Understanding SQL JOIN with Examples SQL Tutorial
Understanding the SQL CREATE DATABASE Statement - SQL CREATE DATABASE Understanding the SQL CREATE DATABASE Statement SQL Tutorial

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You may also like

  1. Understanding the SQL DELETE Statement and Its Variants
  2. SQL SELECT TOP Clause: A Comprehensive Guide
  3. SQL ORDER BY LIMIT – Retrieve Specific Rows from a Database
  4. SQL UPDATE with JOIN
  5. Understanding SQL CROSS JOIN with Examples
  6. IN vs EXISTS in SQL: A Complete Guide

Most Viewed Posts

  1. Top Large Language Models in 2025
  2. Online Shopping System using PHP, MySQL with Free Source Code
  3. login form in php and mysql , Step-by-Step with Free Source Code
  4. Flipkart Clone using PHP And MYSQL Free Source Code
  5. News Portal Project in PHP and MySql Free Source Code
  6. User Login & Registration System Using PHP and MySQL Free Code
  7. Top 10 Final Year Project Ideas in Python
  8. Online Bike Rental Management System Using PHP and MySQL
  9. E learning Website in php with Free source code
  10. E-Commerce Website Project in Java Servlets (JSP)
  • AI
  • ASP.NET
  • Blockchain
  • ChatCPT
  • code Snippets
  • Collage Projects
  • Data Science Project
  • Data Science Tutorial
  • DBMS Tutorial
  • Deep Learning Tutorial
  • Final Year Projects
  • Free Projects
  • How to
  • html
  • Interview Question
  • Java Notes
  • Java Project
  • Java Script Notes
  • JAVASCRIPT
  • Javascript Project
  • JSP JAVA(J2EE)
  • Machine Learning Project
  • Machine Learning Tutorial
  • MySQL Tutorial
  • Node.js Tutorial
  • PHP Project
  • Portfolio
  • Python
  • Python Interview Question
  • Python Projects
  • PythonFreeProject
  • React Free Project
  • React Projects
  • Spring boot
  • SQL Tutorial
  • TOP 10
  • Uncategorized
  • Online Examination System in PHP with Source Code
  • AI Chatbot for College and Hospital
  • Job Portal Web Application in PHP MySQL
  • Online Tutorial Portal Site in PHP MySQL — Full Project with Source Code
  • Online Job Portal System in JSP Servlet MySQL

Most Viewed Posts

  • Top Large Language Models in 2025 (8,613)
  • Online Shopping System using PHP, MySQL with Free Source Code (5,211)
  • login form in php and mysql , Step-by-Step with Free Source Code (4,866)

Copyright © 2026 UpdateGadh.

Powered by PressBook Green WordPress theme