【发布时间】:2013-09-05 20:02:06
【问题描述】:
如何根据TableA 中的另一列Type 更新在另一个表Table B 中找到的TableA 中的列值
例如
表 A
Location Type Value
USA Dog 20
UK Cat 30
表 B
Dog Cat Rabbit
50 70 100
逻辑:
- 如果
tableA.Value = Dog则更新TableA.Value = TableB.Dog - 如果
tableA.Value = Cat则更新TableA.Value = TableB.Cat - 如果
tableA.Value = Rabbit则更新TableA.Value = TableB.Rabbit
注意:只有 3 个选项,所以硬编码是可以的。
结果
表 A
Location Type Value
USA Dog 50
UK Cat 70
【问题讨论】:
标签: sql-server-2008 sql-update insert-update