1、数据库设计
2、SQL
通过文章ID获取文章的评论语句
SELECT
r.*, m.nick_name,
m.avatar
FROM
article_reply r
INNER JOIN member m ON r.member_id = m.id
WHERE
article_id = ?
AND reply_id IS NULL
ORDER BY
create_time DESC
通过评论ID获取相关的回复
SELECT
r1.member_id r1_id,
u1.nick_name nick_name1,
u1.avatar avatar1,
u2.nick_name nick_name2,
u2.avatar avatar2,
r2.*
FROM
article_reply r1
INNER JOIN article_reply r2 ON r1.id = r2.reply_id
INNER JOIN member u1 ON r1.member_id = u1.id
INNER JOIN member u2 ON r2.member_id = u2.id
WHERE
r1.id = ?
ORDER BY
r2.create_time
3、效果