Mysql select - how to get result for threaded / nested messages?

I create a multi-threaded bulletin board and I try to keep it simple. There is a message table, and then a response table, in which there is a "reply_id" field, which can be zero to indicate a top-level response, or a value that indicates a response with a stream.

Am I a little confused about how to make a SELECT call on this type of table?

Reply
-id (every reply gets a unique id)
-message_id (the message it is replying to)
-reply_id (the id of the reply it may be replying to - for threading)
-reply

I know this can be a difficult problem, especially for performance, but I'm really looking for the most basic solution for this.

thanks...

+3
source share
1 answer

"" , .. . Adjacency List. :

  • , node , .
  • - , node .
  • ( ), , -.

" / ?" Closure.

+1

All Articles