mySQL查询:如何从帖子列表中仅选择一条评论? [重复]

问题描述 投票:0回答:1

Table post:id

表post_commentsid,post_id,评论,created_at

请求:

SELECT * from post
left join post_comments on post_comments.post_id = post.id 

此请求返回每个帖子的所有评论。如何限制此查询仅返回最后一条评论?

mysql sql greatest-n-per-group
1个回答
2
投票
有很多方法可以解决每个小组前1名问题。
© www.soinside.com 2019 - 2024. All rights reserved.