当前位置:网站首页>mysql 递归
mysql 递归
2022-06-30 17:46:00 【曹振华】
DROP FUNCTION IF EXISTS GetChildren;
CREATE FUNCTION GetChildren(InputDeptId char(36))
RETURNS VARCHAR(4000)
BEGIN
declare deptIds VARCHAR(4000) default '';
select CONCAT(@pids,',',IFNULL(GROUP_CONCAT(DeptId),'$')) into deptIds from (
select t1.DeptId,
if(find_in_set(UpperId, @pids) > 0,
@pids := concat(@pids, ',', DeptId), 0) as ischild
from (
select DeptId,UpperId from MDM_Dept t
where t.STATUS=1
order by UpperId, DeptId
) t1,
(select @pids := InputDeptId) t2
) t3 where ischild != 0 ;
return deptIds;
END;
select * from MDM_Dept
where FIND_IN_SET(DeptId, GetChildren('b9d22dc7-5651-4e87-a59b-7f11ef178e45'))
select * from
(
select GetFullPath(DeptId) fullPath,DeptId,`Name`,UpperId
from MDM_Dept
where FIND_IN_SET(DeptId, GetChildren('b9d22dc7-5651-4e87-a59b-7f11ef178e45'))
) t order by t.fullPath边栏推荐
- Delete duplicate elements in the sorting linked list ii[unified operation of linked list nodes --dummyhead]
- PC端微信多开
- Where do the guests come from
- PHP uses queues to solve maze problems
- countdownlatch 和 completableFuture 和 CyclicBarrier
- Small program container technology to promote the operation efficiency of the park
- slice
- Leader: who can use redis expired monitoring to close orders and get out of here!
- Lenovo Yoga 27 2022, full upgrade of super configuration
- Tensorflow2 ten must know for deep learning
猜你喜欢

iCloud照片无法上传或同步怎么办?

PC端微信多开

The cloud native landing practice of using rainbow for Tuowei information

煤炭行业数智化供应商管理系统解决方案:数据驱动,供应商智慧平台助力企业降本增效

不同制造工艺对PCB上的焊盘的影响和要求

Entry node of link in linked list - linked list topic

Cobbler轻松上手

Geoffrey Hinton:我的五十年深度学习生涯与研究心法

Multipass Chinese document - setting graphical interface

金融服务行业SaaS项目管理系统解决方案,助力企业挖掘更广阔的增长服务空间
随机推荐
Go Redis连接池
Infineon - GTM architecture -generic timer module
Can go struct in go question bank · 15 be compared?
PyTorch学习(三)
At present, the big guys are joining the two streams of flinksql, cdcmysql and Kafka, and the results are put into MySQL or KA
Hospital online consultation applet source code Internet hospital source code smart hospital source code
Lenovo Yoga 27 2022, full upgrade of super configuration
countdownlatch 和 completableFuture 和 CyclicBarrier
Personally test the size of flutter after packaging APK, quite satisfied
Regular expressions (regular matching)
金融服务行业SaaS项目管理系统解决方案,助力企业挖掘更广阔的增长服务空间
Reading notes of "high EQ means being able to talk"
电子元器件招标采购商城:优化传统采购业务,提速企业数字化升级
The easynvr platform equipment channels are all online. What is the reason for the "network request failure" in the operation?
医院在线问诊小程序源码 互联网医院源码 智慧医院源码
dtd建模
The cloud native landing practice of using rainbow for Tuowei information
Where do the guests come from
如何利用AI技术优化独立站客服系统?听听专家怎么说!
充值满赠,IM+RTC+X 全通信服务「回馈季」开启