PHP Comment reply
This post was last edited by haoren026 on 2013-12-15 21:12:03
I know the problem is very, very elementary. I also searched a lot of posts, but it was quite troublesome, or I was not able to achieve enough.
The problem is this:
I am practicing blogging system, to implement the comment reply function, the request is not high, the guest comments, bloggers reply to comments, can not reply again, only a layer of relationship: Comment-reply. It's so simple.
The data table structure of the methods on the Internet is mostly as follows:
ID: Comment ID
PID: Comment ID of the reply
Content: Comments
I want to know how to find a record of a reply when there are several lines between the record of the comment and the record of the reply, such as:
ID PID
1 0
2 0
3 1//replies and comments are separated by several lines
4 0
This problem is very difficult to solve in the SQL sort reorganization. Help the Great God, thank you very much
share to: more
------Solution--------------------
Fixed level two stories
Http://sqlfiddle.com/#!2/e433e/1
This statement is learned with MySQL moderators
SELECT * from ' comment ' ORDER by if (PID=0,ID,PID) ASC