Thursday, August 11, 2011

SQL Cascading Query

11:12 PM Posted by Unknown No comments
with MessageList
as
(
select MessageID_,ParentID_ from Messages_ where ParentID_='3529'
union all
select m.MessageID_,m.ParentID_ from Messages_ m inner join MessageList ml on m.ParentID_= ml.MessageID_
)
SELECT distinct(MessageID_) FROM MessageList group by MessageID_