create table hit_counter (
cnt int unsigned not null
) engine = InnoDB;
update hit_counter
set cnt = cnt + 1;
create table hit_counter(
slot tinyint unsigned not null primary key,
cnt int unsigned not null
) engine = InnoDB; ```
update hit_counter
set cnt = cnt + 1
where slot = rand() * 100;
select sum(cnt)
from hit_counter;
create table daily_hit_counter (
day date not null,
solt tinyint unsigned not null,
cnt int unsigned not null,
primary key(day, slot)
) engine = InnoDB;
on duplicate key update
来代替:insert into daily_hit_counter
values (current_date, rand() * 100, 1)
on duplicate key update cnt = cnt + 1;
原文:https://www.cnblogs.com/dwtfukgv/p/14678654.html