Answer the question
In order to leave comments, you need to log in
How to get the last comment of each user without a comment ID?
Table with data:
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
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question