我有3个表:帖子,评论和回复
Posts
id
user_id (fk)
content
created_at
updated_at
Comments
id
user_id (fk)
post_id (fk)
content
created_at
updated_at
Replies
id
user_id (fk)
post_id (fk)
comment_id (fk)
content
created_at
updated_at
现在我按照desc顺序编写了由created_at命令的帖子,以便在显示时在最顶层获取最新创建的帖子。我需要做的是将最近创建的帖子或最近评论/回复的帖子放在最顶层。到目前为止,我已经尝试过......
SELECT posts.*, comments.*, replies.*
FROM posts
LEFT JOIN comments
ON posts.id = comments.post_id
LEFT JOIN replies
ON comments.id = replies.comment_id
但这只能让我获得所有个人帖子,评论和回复。接下来我该怎么办?