我有一张桌子T1
Fruit | Quantity
----------------
Apple | 2
Grape | 3
我有表T2
Factor
------
2
我想要最终结果
Fruit | Quantity
----------------
Apple | 4
Grape | 6
有点困惑如何进行更新,因为我的第二张表没有任何我可以加入的ID。 我正在使用RedShift。
答案 0 :(得分:1)
select t1.fruit, t1.quantity * t2.factor
from t1
cross join t2
答案 1 :(得分:0)
UPDATE T1
SET Quantity = Quantity * T2.factor
FROM T2
-- optional
WHERE T1.id = T2.id
见工作sqlFiddle