树函数
来源:互联网 发布:windows启动菜单修改 编辑:程序博客网 时间:2024/05/20 23:37
CREATE FUNCTION `getChildLst`(rootId INT)
RETURNS varchar(1000)
BEGIN
DECLARE sTemp VARCHAR(1000);
DECLARE sTempChd VARCHAR(1000);
SET sTemp = '$';
SET sTempChd =cast(rootId as CHAR);
WHILE sTempChd is not null DO
SET sTemp = concat(sTemp,',',sTempChd);
SELECT group_concat(id) INTO sTempChd FROM treeNodes where FIND_IN_SET(pid,sTempChd)>0;
END WHILE;
RETURN sTemp;
END ;
select * from treeNodes
where FIND_IN_SET(id, getChildLst(0));
select id,pid from treeNodes where id in(
select id from treeNodes where FIND_IN_SET(id, getChildLst(1))
)
RETURNS varchar(1000)
BEGIN
DECLARE sTemp VARCHAR(1000);
DECLARE sTempChd VARCHAR(1000);
SET sTemp = '$';
SET sTempChd =cast(rootId as CHAR);
WHILE sTempChd is not null DO
SET sTemp = concat(sTemp,',',sTempChd);
SELECT group_concat(id) INTO sTempChd FROM treeNodes where FIND_IN_SET(pid,sTempChd)>0;
END WHILE;
RETURN sTemp;
END ;
select * from treeNodes
where FIND_IN_SET(id, getChildLst(0));
select id,pid from treeNodes where id in(
select id from treeNodes where FIND_IN_SET(id, getChildLst(1))
)
0 0
- 树函数
- 二叉树(类模板、函数模板、函数对象、函数指针)
- 函数式 - 主席树 > <
- 函数式线段树
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 空气质量在线检测系统制作 之Smart Airbox 制作流程
- VelocityTracker简单用法
- listView.setLayoutParams
- iOS开发 ARC和MRC混编相关
- Jstat使用详解
- 树函数
- 关于JavaScript与HTML的交互事件
- hdoj 1181 变形课【DFS】
- 南邮 OJ 1397 Decoding
- xcode6 自动添加注释插件攻略
- win7_oracle11g_64位连接32位PLSQL解决方案
- [转]协程 及 Libco 介绍
- POJ2488 A Knight's Journey(dfs)
- HDU 5344 MZL's xor(水题)