SQL Server 2005 recursive query with loops in data - is it possible?

前端 未结 10 1854
野趣味
野趣味 2020-12-06 03:29

I\'ve got a standard boss/subordinate employee table. I need to select a boss (specified by ID) and all his subordinates (and their subrodinates, etc). Unfortunately the rea

10条回答
  •  广开言路
    2020-12-06 04:20

    basicaly if you have loops like this in data you'll have to do the retreival logic by yourself. you could use one cte to get only subordinates and other to get bosses.

    another idea is to have a dummy row as a boss to both company owners so they wouldn't be each others bosses which is ridiculous. this is my prefferd option.

提交回复
热议问题