CREATE TABLE IF NOT EXISTS `count_view` (
`active` date NOT NULL,
`num` int(10) unsigned NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `count_view` ADD PRIMARY KEY (`active`);
REPLACE INTO count_view
SELECT active , sum(num)
FROM (
SELECT CURDATE() active, 1 num
union all
select * from`count_view`
WHERE active = CURDATE()
) as b
group by active