I have a database I store stats in for views.. but I am not sure how to find the top 5 or so viewed items. Here is the table structure:
CREATE TABLE `item_views` (
`id` int(8) NOT NULL auto_increment,
`myid` int(8) NOT NULL,
`ip` varchar(14) NOT NULL,
`date` date NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `item_id` (`myid`,`ip`)
)
It has quite a few rows for each myid. Did I set this up wrong to ge the top items? I'm guessing I need to group the myid's but I would like to know the proper or most efficient way to store stats, since i need the top items frequently.