【发布时间】:2013-09-05 14:25:47
【问题描述】:
我在 http://www.xaluan.com 从事 tintuc 项目
我有两张这样简单的桌子
table articles
ID - Title - Des - CatID
table category
CatID - catTitle
通常我会在类别表上运行循环以接收 CatID 和 catTile,然后在文章表上再次运行循环以使 4 篇最新文章属于该 CatID
这样的网站上的结果
catTitle 1
- lastes article belong to catID 1
- second last artice belong to catID 1
catTitle 2
- lastess article belong to catID 2
- second last article belong to catID 2
我认为循环遍历类别表然后在文章表上为每个 catId 循环多次不是有效方式。
请帮助最有效的mysql查询以获得相同的结果。
非常感谢。
【问题讨论】:
标签: mysql