参考这个写: SELECT * FROM tb_slave_upload_data a INNER JOIN ( SELECT c.locationID,MAX(c.addTime) AS ADDTIME FROM tb_slave_upload_data c WHERE c.isDelete=0 GROUP BY c.locationID ) b ON (a.locationID=b.locationID AND b.addTime=a.addTime) WHERE a.isDelete=0 ;