Answer the question
In order to leave comments, you need to log in
How to get all but the first entries with duplicate users?
There is a table of the form It is uuid, user_id, update_at(timestamp)
necessary to get all the records in which it repeats user_id
and in which update_at < MAX(update_at)
with the current user_id
So far I figured out how to get records with repetitions, but I update_at
haven’t figured out how to filter by yet
SELECT * FROM table WHERE user_id IN (SELECT user_id from table group by user_id having count(*) > 1)
Answer the question
In order to leave comments, you need to log in
SELECT DISTINCT `t1`.*
FROM `table` AS `t1`
JOIN `table` AS `t2`
ON `t2`.`user_id` = `t1`.`user_id`
AND `t2`.`update_at` > `t1`.`update_at`
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question