Home > Database > Mysql Tutorial > mysql-mysq如何查找出所有的评论和回复

mysql-mysq如何查找出所有的评论和回复

WBOY
Release: 2016-06-06 09:41:02
Original
2223 people have browsed it

mysql

所有的评论和回复都放在一张tb_question_answer(id,obid,type,content,user)表里。评论和回复用一字段type来区分。请问mysql如何查找所有的评论和回复?像QQ空间那样,对应一个日志ID,是如何查找出对应的评论和回复的?用一次select的话只能查找到一次回复的内容,如果有多重回复的话,如何写sql呢?
例如是这样的结果:
a:评论
aa:回复a的评论
aaa:回复aa的回复
c:回复a的评论

评论a id=1 一条回复a的回复aa id=2,obid=1 又有一个人看到aa对a的回复,然后对aa进行了回复aaa id=3,obid=1

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template