Update Multiple Data from 1 Table to Other Table in Single Query

Update Multiple Data from 1 Table to Other Table in Single Query.

1. Table A

ID

Name

Age

CourseName

1

Rahul

25

 

2

XYZ

26

 

3

ABC

30

 

4

PQR

22

 

2. Table B

 

ID

Name

CourseName

1

Rahul

C#

2

XYZ

Java

4

PQR

C#

Now  We Update in TableA CourseName.

Query

UPDATE  TableA SET TableA. CourseName = (select CourseName FROM TableB WHERE TableB.ID_ = TableA.ID)

Output

ID

Name

Age

CourseName

1

Rahul

25

C#

2

XYZ

26

Java

3

ABC

30

 

4

PQR

22

C#