首页 > 代码库 > 树型结构查询语句备忘

树型结构查询语句备忘

SELECT TOP 1000 [ID]      ,[ParentID]      ,[Name]      ,[Content]      ,HasChildren = ISNULL((SELECT 1  WHERE EXISTS(SELECT TOP 1 1 FROM t_Tree WHERE ParentID = A.ID)),0)FROM [Test].[dbo].[t_Tree] A

 

树型结构查询语句备忘