【发布时间】:2016-11-09 22:48:42
【问题描述】:
我想根据表 3 和表 2 的值更新表 1
表1
表2
表3
我想更新 table1 的列 'price',其中 table3 中 table1 的 'store_num' 的 store_div 的值等于 table2 中的 store_div。
我已经尝试加入 table1 和 table3 以获取每个 store_num 的 store_div 值,但我不知道将 where 子句指向哪里,因为 table1 上不存在 store_div。
更新将如下所示:
Update Table1 t1 set price = '0'
join Table t3 on t1.store_num = t3.store_num
where ([t1.store_num]'s [store_div] = Table2.store_div)
我不太确定 where 子句。
任何帮助将不胜感激。
【问题讨论】:
-
@John F,您是否尝试将每个商店的价格更新为“0”,该商店位于特定部门中?我只是想更清楚地了解您要做什么。
-
是的,其中商店的部门编号出现在 table2 上
-
嗨@ChrisPickford 我不认为它是重复的,因为我正在尝试更新一个表,其中 where 子句中的值不在将要更新的表中。
标签: sql sql-server