SELECT * FROM carregisterinfo a WHERE (a.plate) IN ( SELECT plate FROM carregisterinfo GROUP BY plate HAVING count(*) >= 1 ) AND id IN ( SELECT max(id) FROM carregisterinfo GROUP BY plate HAVING count(*) >= 1 )
原表数据如下:
SELECT * FROM carregisterinfo a WHERE (a.plate) IN ( SELECT plate FROM carregisterinfo GROUP BY plate HAVING count(*) >= 1 ) AND id IN ( SELECT max(id) FROM carregisterinfo GROUP BY plate HAVING count(*) >= 1 )
原表数据如下: