SQL-如何提取不重复的论坛主题?
在我网站的主页上,我想显示论坛的最新帖子,但我不想两次显示同一主题。我如何修改下面的代码来做到这一点?
http://punbb.informer.com/wiki/punbb13/integration#recent_10_posts
基本上显示最新帖子,但每个论坛主题/线程仅显示一次。
On the home page of my website I want to display the latest posts to the forum however I don't want to show the same topic twice. How can I modify the code below to do this?
http://punbb.informer.com/wiki/punbb13/integration#recent_10_posts
Basically show the latest posts, but only once for each forum topic/thread.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
添加一个条件以仅保留该帖子是主题中最后一篇帖子的记录:
Add a condition to keep only records where the post is the last post in the topic:
如果您只需要每个主题一个值,您可以按主题分组,然后从每个主题中选择最新的帖子。然后,您可以选择前 10 个主题。
我将用 SQL 编写它,您可以将其转换为 PHP:
If you want only one value per topic, you could group by topic, and from each topic select the most recent post. Then, you could choose the top 10 topics.
I'll write it in SQL, and you can translate that to PHP:
将此行更改
为
change this line
to