1,查询指定父类下所有的子

1 with temp as 2 ( 3 select * from bot_EquityFundamentals where Id=7 --父类Id 4 union all 5 select b.*from bot_EquityFundamentals b 6 inner join 7 temp t on (b.ParentId = t.Id) 8 ) 9 select* from temp order by Id;
2,查询指定子类所有的父类

1 with temp as 2 ( 3 select * from bot_EquityFundamentals where Id=2143 --子类Id 4 union all 5 select b.* from bot_EquityFundamentals b 6 inner join 7 temp t on (b.Id=t.ParentId) 8 ) 9 select * from temp;