Updating A Table Using Inner Join In SQL

Sometimes we may need to update some columns in a table in SQL with values from columns of another table. For this purpose we can use inner join with update query as below.
  1. UPDATE t1  
  2. SET t1.somecol1 = t2.somecol2  
  3. FROM table1 t1  
  4. INNER JOIN table2 t2 ON t1.id = t2.id  
With above query, column 'somecol1' of table1 will be updated with values from 'somecol2' of table2 satisfying the inner join condition.