How to get the parent child relation in same table In Sql Server

SELECT

ChildUserType.Id as CategoryId,ChildUserType.Category as CategoryName,

ChildUserType.IsActive,ChildUserType.CategoryURL as CategoryURL,

ChildUserType.CreatedOn,ChildUserType.ParentId,

ParentUserType.Category as ChildParentname,ChildUserType.NoofOrgs

FROM 

[dbo].[Categories] AS ChildUserType

LEFT JOIN 

[dbo].[Categories] AS ParentUserType 

ON 

ChildUserType.ParentId = ParentUserType.Id 

Comments

Popular posts from this blog

Top MNC Interview Questions- Full Stack Developer

Interview Questions-2

How to get the user details, user current level, next level, Rank in sql server