mysql 层次化查询 递归查询父子集(临时表with recursive temp as)

WITH RECURSIVE temp(next_flow_code,sort) AS (
    SELECT next_flow_code,1  FROM aida_flow_definition_info where id=180008
    UNION ALL
    SELECT r.next_flow_code,sort+1 FROM aida_flow_definition_info r,temp t WHERE t.next_flow_code = r.flow_code 
		and  r.flow_id = 180008 and r.next_flow_code is not null
)select DISTINCT temp.* from temp temp order by sort asc

  1、temp 可以自定义 字段名称

https://blog.csdn.net/qq_25851237/article/details/111601646
posted @ 2022-09-20 16:22  随风而逝,只是飘零  阅读(222)  评论(0编辑  收藏  举报