表结构
进行树形结构查询,利用特殊语法进行操作
-
- with recursive t as
- (
- select parent_id , business_name
- from business_line where id = 21
- union all
- select a.parent_id, a.business_name
- from business_line a join t on a.id = t.parent_id
- )
- select business_name from t;
查询结果: