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_
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_