MySQL获取重复记录中最新一条记录
SQL语句:
SELECT * FROM table_name AS ta WHERE ta.唯一键 = ( SELECT max( tb.唯一键 ) FROM table_name AS tb WHERE ta.判断重复的列 = tb.判断重复的列 );
如果想排序加分页查询,SQL语句:
SELECT * able_name AS ta WHERE ta.唯一键 = ( SELECT max( tb.唯一键 ) FROM table_name AS tb WHERE ta.判断重复的列 = tb.判断重复的列 ) ORDER BY ta.CREATE_DATE DESC LIMIT 0,30;
如果还想加更多过滤条件查询,就在最外面添加过滤条件,不能在子查询添加。