0

ReportServer 数据库表中有一个名为“Catalog”的表。它有两列 GUID 类型:“ItemID”和“ParentID”我想在 SQL Server 中构建一个查询,该查询可以返回包含一些记录的数据集,在每条记录中返回 ItemID、ParentID、PossibleChildIDs

例如假设 ItemID = firstGUID 我想要 firstGUID 层次结构中的所有可能的孩子

4

1 回答 1

1

我们在同一个家庭中 如果我们有相同的父
级 这只是层次结构的一个级别
如果记录可以是子级和父级,那么您将需要递归

select family.* 
  from table as member 
  join table as familiy 
    on member.ParentID = family.ParentID 
 where member.ItemID = 'firstGUID'
于 2014-12-03T16:51:17.373 回答