This ?declare @tblCategories table( CategoryID int, CategoryName varchar(15), SubCatOf int)insert into @tblCategoriesselect 1 , 'Plates' , 0 union allselect 2 , 'Big Plates' , 1 union allselect 3 , 'Small Plates' , 1 union allselect 4 , 'Odd Plates' , 1 declare @tblProductCategories table( ProductID int, CategoryID int)insert into @tblProductCategoriesselect 333 , 2 union allselect 234 , 2 union allselect 453 , 3 union allselect 444 , 4 declare @CatID intselect @CatID = 1select *from @tblProductCategories p inner join @tblCategories c on p.CategoryID = c.CategoryIDwhere c.CategoryID = @CatIDor c.SubCatOf = @CatID/*ProductID CategoryID CategoryID CategoryName SubCatOf ----------- ----------- ----------- --------------- ----------- 333 2 2 Big Plates 1234 2 2 Big Plates 1453 3 3 Small Plates 1444 4 4 Odd Plates 1*/
KH