Suppose I have table called Messages
with the following fields:
- MessageID,
- MessageTitle,
- MessageBody,
- MessageDate,
- ReplyTo
The ReplyTo
field is of int
type and can be null
(when the message is not a reply to another message) or the value of some other message's MessageID
. So, a message can, optionally, be set as a reply to an pre-existing message.
Is it possible to have a query that returns a list of records, starting from a particular message and followed by the record to which it is replying. This second record would, in turn, be followed by the message it is a reply to....and so on. I guess there is some kind if recursion involved.
Apologies for not using the correct terminology for what I am trying to achieve. I don't know what it is really called and therefore I don't know what to look for in Google.