删除GROUP BY
子句
UPDATE a_daily
SET a_daily.Turbine_Generation =
(
SELECT sum(o_daily_lcsgeneration.Turbine_Generation)
FROM o_daily_lcsgeneration
WHERE o_daily_lcsgeneration.Location = 1
)
它会导致查询返回多个日期的多个值。
更新 1
UPDATE a_daily a
INNER JOIN
(
select g.Date, sum(g.Turbine_Generation) totalSum
from o_daily_lcsgeneration g
where g.Location = 1
group by g.Date
) b ON a.date = b.date
SET a.Turbine_Generation = b.totalSum
WHERE a.location = 1
或者
UPDATE a_daily a
LEFT JOIN JOIN
(
select g.Date, sum(g.Turbine_Generation) totalSum
from o_daily_lcsgeneration g
where g.Location = 1
group by g.Date
) b ON a.date = b.date
SET a.Turbine_Generation = COALESCE(b.totalSum, 0)