【发布时间】:2010-08-11 13:39:34
【问题描述】:
我在更新表格时遇到问题,我确定它非常简单,但我在这里转圈圈。
我要更新的表'table1'数据格式如下:
[Month] Figure
----------------------------------
2010-05-01 00:00:00.000 1.0000
2010-06-01 00:00:00.000 1.0000
2010-07-01 00:00:00.000 1.0000
2010-08-01 00:00:00.000 1.0000
包含更新数据的表“data1”的格式如下:
[Month] Figure
----------------------------------
2010-05-01 00:00:00.000 0.7212
2010-08-01 00:00:00.000 1.2351
我使用的SQL和错误信息如下。
UPDATE t1
SET t1.figure = (SELECT figure from data1)
FROM table1 t1 JOIN data1 d1
ON (t1.[month] = d1.[month])
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.
我需要一个while循环来遍历每一行吗?
我希望最终结果如下:
[Month] Figure
----------------------------------
2010-05-01 00:00:00.000 0.7212
2010-06-01 00:00:00.000 1.0000
2010-07-01 00:00:00.000 1.0000
2010-08-01 00:00:00.000 1.2351
非常感谢。
【问题讨论】:
标签: sql sql-server join sql-update