sql - Updating two tables we getting duplicates -
i have 2 tables
emp
:
id name sal deptno ------------------- 1 x 10 2 b x 20 3 c x 20
dept
:
id sal deptno ------------- 1 100 10 2 200 20 3 300 20
here want update sal
column in emp
table
update emp set sal = d.sal emp e left bring together dept d on e.deptno = d.deptno
after executing query getting
id name sal deptno ------------------ 1 100 10 2 b 200 20 3 c 200 20
but want
id name sal deptno ------------------ 1 100 10 2 b 200 20 3 c 300 20
try 1 :
update emp set sal = d.sal emp e left bring together dept d on e.id = d.id
sql
No comments:
Post a Comment