mysql查询不同用户(操作记录)的最新一条记录

先用MAX(time) 和 group by item_id 查询出不同的item_id对应的最大时间,然后再在外面连表查询,查询 表中 item_id 和login_time 时间 相等于刚才的查询记录的记录


具体语句如下

 
select a.* from reyo a  

join (select item_id,max(login_time) as time from reyo group by item_id) b

on a.item_id = b.item_id

and a.login_time = b.time

posted @ 2020-12-20 15:56  锐洋智能  阅读(3353)  评论(0编辑  收藏  举报