单表递归,查询组织及其自组织的内容信息

select * from system_organization where id = 1
    union all
    select * from system_organization
    where id in (
        select 
        t3.id 
        from (
                select t1.id,
                if(find_in_set(t1.parent_id, @pids) > 0, @pids := concat(@pids, ,, t1.id), 0) as ischild
                from (
                         select id,parent_id from system_organization t where t.status = 1 
                        ) t1,
-- @pids := 1 这里就是赋值 需要查询的父节点id为1的 及其子组织的id (
select @pids := 1 id) t2 ) t3 where t3.ischild != 0 ) order by id

 

单表递归,查询组织及其自组织的内容信息

上一篇:如何处理C++编译webrtc无法成功获取sdp的问题?


下一篇:【技术开发】构建pion webrtc运行broadcast示例步骤