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