只需要来自两个表的不同行值
像..
ID Name Salary
1 ABC 2000
2 XYZ 4000
3 Suresh 6000
ID Name Salary
1 ABC 3000
2 XYZ 5000
3 Suresh 6000
如果我更新第一个表,这里我根据条件从源表中保存了目标表中的特定行,现在我想比较两个表的列值..哪些列值更新...请帮帮我
ID OldSalary NewSalary
1 2000 3000
2 4000 5000
答案 0 :(得分:2)
你走了:
select newTable.ID, oldTable.Salary as OldSalary, newTable.Salary as NewSalary
from oldTable
join newTable on oldTable.ID = newTable.ID
where oldTable.Salary <> newTable.Salary;