Home Forums SQL Server 2008 T-SQL (SS2K8) Help needed in Relational Logic RE: Help needed in Relational Logic
KGJ-Dev
SSCertifiable
Points: 5780
More actions
December 22, 2014 at 7:12 am
#1765976
Finally i came up with
SELECT DISTINCT Parent
FROM @T WHERE Child = @Id OR Parent = @Id
UNION
SELECT DISTINCT B.Child
FROM @t A INNER JOIN @t B
ON A.Parent = B.Parent
WHERE A.Child = @Id OR A.Parent = @Id
any other suggestions.