我有一句话
要达到INSERT INTO table1 (count)
select count(b.c1) count
from table2 b
where date(b.date) =...
group by b.page_hash
ON DUPLICATE KEY UPDATE count=count+b.count就是说假如存在重复的情况是把原来的值加上现在查出来的值看了网上的列子重复的时候都是随便+1 没有说这种情况如INSERT INTO ipstats VALUES('192.168.0.1', 1) ON DUPLICATE KEY UPDATE clicks=clicks+1;
要达到INSERT INTO table1 (count)
select count(b.c1) count
from table2 b
where date(b.date) =...
group by b.page_hash
ON DUPLICATE KEY UPDATE count=count+b.count就是说假如存在重复的情况是把原来的值加上现在查出来的值看了网上的列子重复的时候都是随便+1 没有说这种情况如INSERT INTO ipstats VALUES('192.168.0.1', 1) ON DUPLICATE KEY UPDATE clicks=clicks+1;
select count(b.c1) count
from table2 b
where date(b.date) =...
group by b.page_hash
ON DUPLICATE KEY UPDATE count=count+values(count)另外你的count 是保留字,建议加上`count`
第一个count是table1的原值 还是 第2个是
官方文档我一直有的 关于 insert into select ON DUPLICATE KEY UPDATE 是在介绍insert的时候讲的
但我没找到我说的这种情况