pradeepbliss
Starting Member
28 Posts |
Posted - 2014-10-07 : 09:43:12
|
solution:;with category as ( SELECT categoryid, category,belongsto, categoryid as cbelogns, CAST((category) AS VARCHAR(1000)) AS 'Cg' FROM item.itemcategory WHERE belongsto=0 UNION ALL SELECT t.categoryid, t.category,t.belongsto, a.cbelogns, CAST((a.Cg + '->' + CAST((t.category) AS VARCHAR(1000))) AS VARCHAR(1000)) AS 'Cg' FROM item.itemcategory AS t JOIN category AS a ON t.belongsto = a.categoryid and t.CategoryID in(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,37,38,39,40,41,42,43,45))select * from category where categoryid=43categoryid category belongsto cbelogns Cg43 Nixon Bag 42 35 Electronics->Digital Camera->DSLR Lens->Canon ->Canon Bag->Nixon Bag |
|
|