CREATE TABLE `comments` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`user_id` int(10) unsigned NOT NULL,
`text` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `comments` (`id`, `user_id`, `text`) VALUES
(1, 1, 'hello'),
(2, 1, 'omg'),
(3, 1, 'last'),
(4, 2, 'ko ko ko');
SELECT max(id), user_id, text
FROM `comments`
GROUP BY user_id