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 with JOIN

SQL UPDATE with JOIN

Posted on February 16, 2025February 16, 2025 By Rishabh saini No Comments on SQL UPDATE with JOIN

SQL UPDATE with JOIN

The SQL UPDATE JOIN statement allows us to update a table by using another table based on a specific condition. This is particularly useful when we have the latest data from an external system and need to update our primary table accordingly.

For example, let’s say we have a users table that needs to be updated with the latest information from a users_backup table. In such a case, we use an INNER JOIN between the target table and the source table using a common identifier, such as the user ID.

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

SQL UPDATE JOIN Syntax

UPDATE users u  
INNER JOIN users_backup ub  
ON u.user_id = ub.user_id  
SET u.user_name = ub.user_name,  
    u.email = ub.email  
WHERE u.user_id IN (101, 102);

This query updates the users table with the latest user_name and email from the users_backup table where the user_id matches.

Using Multiple Tables in SQL UPDATE with JOIN

Let’s create two different tables, employees and employees_new, and perform an update operation using JOIN.

Creating Table 1: employees

CREATE TABLE employees (
    emp_id INT PRIMARY KEY,
    emp_salary INT,
    emp_role VARCHAR(100)
);

INSERT INTO employees (emp_id, emp_salary, emp_role)  
VALUES (101, 50000, 'Developer'),  
       (102, 60000, 'Designer'),  
       (103, 70000, 'Manager'),  
       (104, 80000, 'Director');

Creating Table 2: employees_new

CREATE TABLE employees_new (
    emp_id INT PRIMARY KEY,
    emp_salary INT,
    emp_role VARCHAR(100)
);

INSERT INTO employees_new (emp_id, emp_salary, emp_role)  
VALUES (103, 75000, 'Senior Manager'),  
       (104, 85000, 'Senior Director');

Viewing the Initial Data

To verify our data before updating, run:

SELECT * FROM employees;
SELECT * FROM employees_new;

employees Table Before Update:

emp_idemp_salaryemp_role
10150000Developer
10260000Designer
10370000Manager
10480000Director

employees_new Table Before Update:

emp_idemp_salaryemp_role
10375000Senior Manager
10485000Senior Director

Updating Table Using JOIN

Now, let’s update the employees table with the latest salaries and roles from employees_new.

UPDATE employees e  
INNER JOIN employees_new en  
ON e.emp_id = en.emp_id  
SET e.emp_salary = en.emp_salary,  
    e.emp_role = en.emp_role  
WHERE e.emp_id IN (103, 104);

After executing the update, check the table contents:

SELECT * FROM employees;

employees Table After Update:

emp_idemp_salaryemp_role
10150000Developer
10260000Designer
10375000Senior Manager
10485000Senior Director

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

Conclusion

The SQL UPDATE JOIN statement is a powerful tool when you need to update one table using another. By using INNER JOIN, we can efficiently merge data and ensure that our database reflects the latest updates. This approach is commonly used in data synchronization, ETL processes, and enterprise applications to keep records accurate and up-to-date.

Start using UPDATE JOIN in your SQL queries to optimize your database updates effortlessly!


sql update with join w3schools
sql update with join postgres
mysql update with join
sql update with join oracle
sql update with join and where clause
update query with inner join in sql server
hana sql update with join
snowflake update with join
postgresql update with join
sql update

Post Views: 649
SQL Tutorial Tags:data manipulation with sql, data retrieval with sql, how to update with join in sql, problem with full table scan, sql joins with example, sql joins with examples, sql update with join, update a table with join, update query with join, update statement in oracle with join, update statement with join, update table with inner join in sql server, update with cte, update with join, update with merge, update within transaction, vlookup with multiple columns

Post navigation

Previous Post: Python vs Scala
Next Post: Django Login and Registration System with Source Code

More Related Articles

SQL SELECT TOP SQL SELECT TOP Clause: A Comprehensive Guide SQL Tutorial
SQL DELETE JOIN SQL DELETE JOIN: A Comprehensive Guide SQL Tutorial
Rename Database in SQL Like a Pro : A Comprehensive Guide - Rename Databases in SQL Rename Database in SQL Like a Pro : A Comprehensive Guide SQL Tutorial

Leave a Reply Cancel reply

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

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. News Portal Project in PHP and MySql Free Source Code
  5. Flipkart Clone using 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

Copyright © 2026 UpdateGadh.

Powered by PressBook Green WordPress theme