基本的に私はこのようなものを持っています:
UPDATE
Table
SET
Table.col1 = other_table.col1,
FROM
Table
INNER JOIN
other_table
ON
Table.id = other_table.id
問題は、次のような選択で更新したいということcol1
です:
SELECT SUM(col1) FROM other_table WHERE Table.id = other_table.id AND period > 2011
編集
正解:
UPDATE bestall
INNER JOIN (SELECT bestid,SUM(view) as v,SUM(rawView) as rv
FROM beststat
WHERE period > 2011 GROUP BY bestid) as t1
ON bestall.bestid = t1.bestid
SET view = t1.v, rawview = t1.rv