How to Update Data Using join in SQL

In this article I am going to explain how to update data using join in SQL.
  • 2038

Introduction

In this article I am going to explain how to update data using join in SQL. Join operator is used to fetch data from two or more than two table.  If you want to update any value in a table based on condition in other table then we use join. Join create a relation between two table.

Statement that update data in mcninvoices table

UPDATE dbo.mcninvoices
SET invoicetotal=50000
FROM dbo.mcninvoices JOIN dbo.mcnvendors
ON dbo.mcninvoices.vendorid = dbo.mcnvendors.vendorid
WHERE vendorname='vipendra'

Data in macinvoices table before update operation

inv111.jpg

Data in macinvoices table after update operation 

Clipboard03.jpg


© 2020 DotNetHeaven. All rights reserved.