0

是否可以在单个原子查询中执行以下行?

CREATE TABLE tmp AS 
(
    SELECT fooId, SUM(amount) AS amount 
    FROM foo 
    GROUP BY fooId
);
TRUNCATE TABLE foo;
INSERT INTO foo (SELECT fooId, amount FROM tmp);
DROP TABLE tmp;
4

1 回答 1

1

我认为您正在尝试更新表格中的总数?尝试

REPLACE INTO foo (fooID, amount) 
SELECT fooID, sum(Amount) FROM foo
于 2012-09-18T10:08:59.643 回答