我正在尝试使用其中的 select 运行 mysql 更新查询,但出现错误。查询是这样的:
UPDATE keywords_stats_google_temp SET (Impressions_chg, Clicks_chg, AveragePosition_chg, Ctr_chg, AverageCpc_chg, CurrentMaxCpc_chg, FreeJoins_chg, PaidJoins_chg) = (SELECT
SUM(Impressions) AS Impressions,
SUM(Clicks) AS Clicks,
SUM(Impressions*AveragePosition)/SUM(Impressions) AS AveragePosition,
(SUM(Clicks)*revenue_price)/SUM(Impressions) AS Ctr,
SUM(Spend)/SUM(Clicks) AS AverageCpc,
CurrentMaxCpc,
SUM(free_joins) AS FreeJoins,
SUM(paid_joins) AS PaidJoins
FROM (SELECT KeywordId FROM keywords_stats_google_temp) a JOIN keywords_stats_google_naughtymeetings b ON b.KeywordId = a.KeywordId WHERE b.TimePeriod >= '2012-04-01 00:00:00'
AND b.TimePeriod <= '2012-04-23 00:00:00' GROUP BY a.KeywordId, MatchType)
但我只收到“#1064 - 您的 SQL 语法有错误;请查看与您的 MySQL 服务器版本相对应的手册,以了解在 '(Impressions_chg, Clicks_chg, AveragePosition_chg, Ctr_chg, AverageCpc_chg, Curr' 附近使用的正确语法在第 1 行"
有人可以帮我吗?
谢谢!