首页 > 数据库 >mysql 层次化查询 递归查询父子集(临时表with recursive temp as)

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

时间:2022-09-20 16:36:39浏览次数:95  
标签:层次化 sort code recursive temp flow 查询 next

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

标签:层次化,sort,code,recursive,temp,flow,查询,next
From: https://www.cnblogs.com/zxf330301/p/16711504.html

相关文章

  • Dapper查询返回数组
     ///<summary>///根据用户昵称查询OpenID,模糊查询可能查出多个OpenID///</summary>///<paramname="nickName"></param>......
  • MyBatisPlus-范围查询、模糊查询及排序查询
    MyBatisPlus-范围查询、模糊查询及排序查询原文链接:https://blog.csdn.net/m0_61961937/article/details/125967684一、范围查询二、模糊查询三、排序查询一、范围查......
  • Linux操作系统中查询Oracle数据库版本号
    操作步骤两种方式:----在Linux系统桌面上操作(1)若在Linux系统桌面上操作,使用快捷键【ctrl+alt+t】打开Linux终端命令行模式;(2)在Linux终端命令行中输入sqlplus命令进入Oracl......
  • Mybatis plus 查询
    1、子查询//管理主管查询IntegermanageSupervisor=query.getManageSupervisor();if(manageSupervisor!=null){......
  • Oracle元数据查询总结
     selectDISTINCT(OWNER)fromall_tablesselectTABLE_NAMEfromall_tableswhereOWNER='WZZLSDB'selectA.OWNER,A.TABLE_NAME,A.NUM_ROWS,A.NUM_ROWS*A.......
  • Mysql系列---【使用慢日志查询分析sql语句】
    1.查看慢日志是否开启mysql>showvariableslike'slow_query%';+---------------------------+----------------------------------+|Variable_name|......
  • SQL Server 递归查询上级或下级组织数据
    查询下级(包括自身)WITHTempTableAS(SELECTID,Name,ParentIDFROMtableWHEREIDin(25)UNIONALLSE......
  • 批量查询更新
    --批量查询插入数据INSERTintodts_user_spread_mark_back(id,product_user_id,create_time)selectid,product_user_id,create_timefromdts_user_spread_mark--批......
  • jdk8集合查询
    List<String>ids=list.stream().map(ContractModificationBasicInfoDTO::getUuid).collect(Collectors.toList());privateCompletedBidSectionInfoDTOentityToDTO(Bi......
  • 保险支付查询delphi
    保险支付查询delphiunitUnit_V_Payment;interfaceusesWindows,Messages,SysUtils,Variants,Classes,Graphics,Controls,Forms,Dialogs,Unit_Child_T......