I now have a table of statistics that you want to group on a field and then, based on the update time, get the latest record for each group. The name feels quite simple a need, however no idea, of course, is asked Niang.
Degree Niang's answer is very unified, however all do not work, are error, do not know is because of mysql5.7 reason, but I remember group by also can not find the whole record, why Baidu can, think no solution!
Find an example from the Internet:
Each gets the latest record of last_updated_date according to the USER_ID group.
Select Id,user_id,problems,last_updated_date from (select * from t_iov_help_feedback order by U ser_id, last_updated_date DESC) b GROUP by b.user_id;
Obviously, this will be an error in my SQL.
So I used the correlation query on followed by two conditions
SELECT * FROM (select User_id,max (last_updated_date) group by user_id) as temp left join T_iov_help_feedback as T on temp. user_id=t.user_id and Temp.last_updated_date=t.last_updated_date;
So we can find out. Write so much first, and then have time to study the argument carefully.
MySQL gets the latest records based on the update time based on a field group