SQL Update Join

SQL Update Join statement is used to update the column values of records of the particular table in SQL that involves the values resulting from cross join that is being performed between two or more tables that are joined either using inner or left join clauses in the update query statement where the column values that are being updated for the original table can be assigned the values from other table’s column values that are the table that has been joined in the query statement of an Update query.

UPDATE table_to_update
ON table_to_update.column_name1 = another_table2.column_name2
another_table 2
ON table_to_update.column_name3 = another_table2.column_name4 ....] SET table_to_update.column_name5 = another_table.column_name6
[WHERE any_restrictions];

table_to_update is the name of the original table whose column values we wish to update. another_table is the name of the table with which we have to join the original table depending on certain column values that are matched, which are specified in the ON clause of the JOIN. The join can be either the inner join or the left join. The values that we want to assign to the original table’s column should be specified in the SET statement after the joins with multiple tables are defined in the query statement. We can set as many column values of the table_to_update table as we want and assign them the values that may result from the column values of other joined tables.

Working of Update Join in SQL
  • When a simple update statement is written in SQL, we can update the records of one table and assign the values that we want to the columns of that table in which we can update all or some of the columns by specifying the condition in the where clause.
  • But in situations where we want to assign the column values of one table to column values of another table, we can make the use of an update join statement.
  • Note that at a time, only columns of a single table can be updated in an update join statement. The advantage resides in the assignation of the column values from different tables.
  • The update join works with either an inner join that takes into account the common matched records of both the tables or with a left join that considers all the records of the left side table and the matched records while updating.
  • We can update all, or some of the records from the query of update join by specifying conditions in the where clause.

Copyright 1999- Ducat Creative, All rights reserved.

Anda bisa mendapatkan server slot online resmi dan terpercaya tentu saja di sini. Sebagai salah satu provider yang menyediakan banyak pilihan permainan.