本文就和大家一起深入研究下mysql中group by与order by.下面是我模拟我的内容表
我现在需要取出每个分类中最新的内容
select * from test group by category_id order by `date`
结果如下
明显。这不是我想要的数据,原因是msyql已经的执行顺序是
引用
写的顺序:select … from… where…. group by… having… order by.. 执行顺序:from… where…group by… having…. select … order by…
所以在order by拿到的结果里已经是
- 1
- 2
- 3
前往页