字段的某记录相同,但是时间不同,找到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);

例如此时:你有两条数据他们的command字段相同,但是时间不一致,此时你需要找到最新一天的记录的command相同的id。即此时找到2

那么就可以按照上述SQL语句书写

猜你喜欢

转载自blog.csdn.net/weixin_43135178/article/details/112186550