Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.0k views
in Technique[技术] by (71.8m points)

评论及回复表查询

表结构
message(id, reply_list,...)
reply_message(reply_id, ...)

查询结果
[

{
    id: ""
    ...,
    reply_list: [
        {
            reply_id: "",
            ...
        }
    ]
}

]
查询诉求:
查询message表里所有数据,取每条数据里的id去reply_message表里查询所有与reply_id相等的数据拼到reply_list里;
各位大佬给看看,后端小白刚入门


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

这种树结构 加一个字段path ,比如你的帖子是1,层回复就是1,1,层中回复就是1,1,1,查询的时候 直接like就行了


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...