Hi,I have a table of messages. Each row has an ID and a Parent ID. I would like to query this table so that I can pass in the MessageID and get a list starting with that message amd all of the replies to that message in descending order.So for messageid 12070 I would want a result set like this:messageid parentid frommemberid tomemberid subject12070 12067 217124 260132 RE: RE: this is a message12067 12043 260132 217124 RE: this is a message12043 0 217124 260132 this is a message
Here is some sample data to work with and many thanks for your help!Create Table #MyTemp( messageid bigint ,parentid bigint ,frommemberid bigint ,tomemberid bigint ,subject varchar(200))Insert Into #MyTemp (messageid, parentid, frommemberid, tomemberid, subject) Values(12070, 12067, 217124, 260132, 'RE: RE: this is a message')Insert Into #MyTemp (messageid, parentid, frommemberid, tomemberid, subject) Values(12067, 12043, 260132, 217124, 'RE: this is a message')Insert Into #MyTemp (messageid, parentid, frommemberid, tomemberid, subject) Values(12043, 0, 217124, 260132, 'this is a message')Insert Into #MyTemp (messageid, parentid, frommemberid, tomemberid, subject) Values(2902, 120, 8456, 9541, 'Hey Yo~!')Insert Into #MyTemp (messageid, parentid, frommemberid, tomemberid, subject) Values(9920, 16, 98456, 35124, 'Check this out')Select *From #MyTempDrop Table #MyTemp
JBelthoff• Hosts Station is a Professional Asp Hosting Provider› As far as myself... I do this for fun!