
MYSQL查询每个分类下日期最大的一条数据
查询类型的一条
SELECT * from test GROUP BY type;

查询日期最大
SELECT * FROM test ORDER BY type,date desc

结合该数据整合 用子查询
SELECT * from (SELECT * FROM test ORDER BY type,date desc) a
GROUP BY type ;

还有一种用group_concat
group_concat的作用是将小组里的字段里的值进行串联起来
SUBSTRING_INDEX (被截取字段,关键字,关键字出现的次数)
先排序-后分组-再查询
select * from `test` where id in(select SUBSTRING_INDEX(group_concat(id order by `date` desc),',',1) from `test` group by type ) order by `date` desc