A record of the field is the same, but the time is different, find the latest data in MySQL

@Select("select id from cmd_history where command=#{command,jdbcType=VARCHAR} and send_time=(select max(send_time) from cmd_history where command=#{command,jdbcType=VARCHAR})")
String checkIfExist(@Param("command") String command);

For example, at this time: you have two pieces of data whose command field is the same, but the time is inconsistent. At this time, you need to find the same id of the command of the latest day's record. That is to find 2

Then you can write according to the above SQL statement

Guess you like

Origin blog.csdn.net/weixin_43135178/article/details/112186550