I have a simple table as shown below.
CREATE TABLE `stats` (
`id` int(11) NOT NULL auto_increment,
`zones` varchar(100) default NULL,
`date` date default NULL,
`hits` int(100) default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=latin1;
So, just keep a simple hit counter for each zone per day.
But I just want to increase the value of hits on the same day.
I tried MYSQL DUPLICATE KEY UPDATE, but this does not work, because I can have many zones on different dates, so I can not make them unique or dates.
So, the only way I can think of is to first make a request to see if the date exists, and then make a simple if () to insert / update
This is the best way to do such a task, as there can be many 1000 hits per day.
Hope this makes sense :-).
And thanks if you can advise.
Lee source
share