I need to get the latest records, which are repeated more than two times.
structure:
CREATE TABLE IF NOT EXISTS `tags` (
`tag_n` int(10) NOT NULL AUTO_INCREMENT,
`post_n` int(10) NOT NULL,
`tag` varchar(30) COLLATE utf8_bin DEFAULT NULL,
PRIMARY KEY (`tag_n`),
KEY `tag` (`tag`),
KEY `post_n` (`post_n`),
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
Records:
SELECT * FROM tags ORDER BY post_n DESC LIMIT 0 , 30
My query:
SELECT tag, COUNT(post_n) AS tags_count
FROM tags
GROUP BY tag HAVING tags_count>=2
ORDER BY post_n DESC LIMIT 5
But I get wrong results, latest must be "xpro", can't understand what`s wrong.
Any ideas?
p.s. sorry for my english.