Answers
如果你的comment_id是自增长的话
sql
select * from comments where comment_id in ( select max(comment_id) as comment_id from comments where user_id in (1, 2, 3, 4, 5) group by user_id )
如果comment_id不是自增长,create_time也可以将就,同一用户应该不会出现create_time重复的情况
sql
select * from comments where create_time in ( select max(create_time) as create_time from comments where user_id in (1, 2, 3, 4, 5) group by user_id ) and user_id in (1, 2, 3, 4, 5)
puruspa
answered 9 years, 10 months ago