先用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