Ten przykład powinien wszystko przedstawić
DROP TABLE IF EXISTS `content`;
CREATE TABLE `content` (
`id` mediumint(8) UNSIGNED NOT NULL AUTO_INCREMENT,
`body` text NOT NULL,
`created_at` int(10) UNSIGNED NOT NULL,
`category` int(10) UNSIGNED NOT NULL,
PRIMARY KEY (`id`)
);
INSERT INTO `content` (`body`, `created_at`, `category`) VALUES ('foo', 1, 1), ('bar', 2, 1), ('foobar', 1, 2);
SELECT `t2`.* FROM (SELECT `category`, MAX(`created_at`) AS `created_at` FROM `content` GROUP BY `category`) AS `t1` JOIN `content` AS `t2` ON `t2`.`category` = `t1`.`category` AND `t2`.`created_at` = `t1`.`created_at`