sql with 递归查询(单表多级查询)

 

with unionTable as

(
   SELECT * FROM FmAccountItems WHERE ItemId = '100'
   union all
   select subTable.* from FmAccountItems subTable join unionTable parentTable on subTable.ParentItemId=parentTable.ItemId
)
select * from unionTable

posted on 2020-04-20 10:25  郑土  阅读(532)  评论(0)    收藏  举报

导航