SELECT
t3.college_code
FROM
(
SELECT
t1.college_code,
IF
( find_in_set( t1.parent_org_code, @pids ) > 0, @pids := concat( @pids, ',', t1.college_code ), 0 ) AS ischild
FROM
( SELECT college_code, parent_org_code FROM t_college t WHERE t.STATUS = 1 ORDER BY parent_org_code, college_code ) t1,
( SELECT @pids := '' college_code ) t2
) t3
WHERE
t3.ischild != 0 表结构: t_college: id, college_code (机构编码), parent_org_code (父机构编码)

mysql 查询所有子节点的更多相关文章

  1. mysql 查询所有子节点的相关数据

    定义一个函数 ) CHARSET utf8 BEGIN ); ); SET sTemp = '$'; SET sTempChd =cast(rootId as CHAR); WHILE sTempCh ...

  2. MySql 利用函数 查询所有子节点

    前提:mysql  函数  find_in_set(str,strlist), cast(value as type)   一.find_in_set(str,strlist):如果字符串str是在的 ...

  3. 根据id查询所有子节点/父节点,mysql 以及ssm前后台处理流程

    1.所示案例数据表结构设计如下所示: 2.案例数据如下所示: 3.mysql查询语句可以查询出父级目录信息: 注意:自己的数据表表名称,切记手动修改,字段名称(特别注意id,parent_id字段名称 ...

  4. MySQL递归查询所有子节点,树形结构查询

    --表结构 CREATE TABLE `address` ( `id` int(11) NOT NULL AUTO_INCREMENT, `code_value` varchar(32) DEFAUL ...

  5. sql 查询所有子节点示例

    每天学习一点点 编程PDF电子书.视频教程免费下载:http://www.shitanlife.com/code <!-- 查询机构的所有子机构 --> <select id=&qu ...

  6. MySQL 查询所有子级函数

    BEGIN DECLARE sChildList VARCHAR(4000); DECLARE sChildTemp VARCHAR(4000); SET sChildTemp =cast(rootI ...

  7. mysql 查询 所有 父节点 单表

    SELECT T2.* FROM ( SELECT @r AS _id, ( SELECT @r := parent_id FROM tp_module_rel WHERE REL_ID = _id ...

  8. SQLServer查询所有子节点

    用CTE递归 ;with f as  ( select * from tab where id=1 union all select a.* from tab as a inner join f as ...

  9. SQL根据某一父节点查询所有子节点,无限

    ;with cte as( select id,ParentCategoryId from Category where id = 17 union all select a.id,a.ParentC ...

随机推荐

  1. React准备工作

    一.环境准备 使用react官方推荐的脚手架create-react-app 1.安装nodejs 2.npm install -g create-react-app  //全局安装脚手架 3.cre ...

  2. app中使用

    KeepLive.startWork(this, KeepLive.RunMode.ROGUE, ForegroundNotification("Title", "mes ...

  3. EZOJ #387字符串

    分析 似乎ttl的模拟赛t3总是折半搜索? 先把所有串转化为每个字母的0/1状态 之后我们将所有字符串分为两半 分别枚举状态 我们发现只有左右两边的字母状态相等才能保证这个集合合法 所以我们在搜左半边 ...

  4. JS-Number 的精度

    JS 使用 IEEE 754 的双精度数表示数字,1 位符号,10 位指数,53 位底数. 所以 JS 数字精度近似为 15.95 位 10 进制(10 ** 15.95). 也就是说整部加小数部分超 ...

  5. day34—JavaScript实现DOM操作

    转行学开发,代码100天——2018-04-19 1.通过JavaScript元素属性的操作 三种: window.onload =function(){ var oTxt = document.ge ...

  6. Integer自动装箱和拆箱

    Integer a=3;   =>    Integer a=Integer.valueOf(3); /** *@description: 自动装箱和拆箱 *@auther: yangsj *@ ...

  7. 重写hashCode方法,导致内存泄漏

    package com.nchu.learn.base.reflect; import org.junit.Test; import java.util.Collection; import java ...

  8. 【ABAP系列】SAP ABAP模块-ABAP动态指针写法的精髓部分

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP模块-ABAP动 ...

  9. 【ABAP系列】SAP 的逻辑数据库解析

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP 的逻辑数据库解析   前 ...

  10. 让gitlab暴露node-exporter供外部prometheus使用

    花了两天部署了一套监控服务 prometheus+node-exporter+grafana,公司的gitlab服务器准备部署node-exporter的时候突然发现gitlab已经有了这些服务, 也 ...