【发布时间】:2014-02-17 02:00:41
【问题描述】:
我从这样的查询开始:
insert into summary ( col1, col2, Total )
select col1, col2, count(col4) as total from importdata
where col1 = 'abc' and col4 in ('1A', '2A')
group by col1, col2
order by col1, col2
而且我无法确定正确的“重复”子句。我认为我需要的子句是
on duplicate key update total=count(col4)
我把它放在查询的最后一行和 where 子句之后的行,但两者都产生了错误。我的条款甚至正确吗?它需要去哪里?
(最坏的情况我可以使用“插入忽略”,但我认为进行更新会更好。)
【问题讨论】: