sql迭代 因为parentid is null 要有parentid为null的记录
来源:互联网 发布:mac netbeans tomcat 编辑:程序博客网 时间:2024/06/04 18:34
用这种迭代,由于有start with parentid is null,所以第一行的查询必须有t.parentid is null的记录,如果被条件过滤掉了就加or t.parentid is null,
在用连接过滤时,如果有重复用distinct(只有放在第一列才不会出错),没有的列 要用常量补齐(0 leave1,不用'0'是因为和数据类型要匹配,也可直接用null)
select * from (select * from
(
select distinct(t.id) id, t.name name,t.parentid parentid ,0 leave1,'1' leave from opm_menufolder t left join opm_menuitem oo on t.id=oo.menufolderid where oo.id in (select MenuItemId from OPM_ROLELIMIT where ROLEID='ff8080814dc41486014dcd88e7830030') or t.parentid is null
union all select distinct(o.id) id, o.name name,o.menufolderid ,o.level1 leave1,'2' leave from opm_menuitem o where o.id in (select MenuItemId from OPM_ROLELIMIT where ROLEID='ff8080814dc41486014dcd88e7830030')
union all select distinct(l.id) id, l.name name,l.menuitemid ,l.level1 leave1,'3' leave from opm_menuitemlimit l where l.id in (select MENUITEMLIMITID from OPM_ROLELIMIT where ROLEID='ff8080814dc41486014dcd88e7830030')
)
start with parentid is null connect by prior id=parentid ORDER SIBLINGS BY parentid)
select * from (select * from
(
select t.name name,t.id id,t.parentid parentid ,0 leave1,'1' leave ,null uri from opm_menufolder t
union all select o.name name,o.id id,o.menufolderid,o.level1 leave1,'2' leave, o.uri uri from opm_menuitem o
union all select l.name name,l.id id,l.menuitemid ,l.level1 leave1,'3' leave , l.uri uri from opm_menuitemlimit l
)
start with parentid is null connect by prior id=parentid ORDER SIBLINGS BY parentid)
- sql迭代 因为parentid is null 要有parentid为null的记录
- 按id和parentid给记录分级
- SQL查询为空的字段的写法is null 而不是=null
- 关于同时查询父子名称的SQL查询语句的写法 id name parentId parentName
- 关于同时查询父子名称的SQL查询语句的写法 id name parentId parentName
- SQL递归函数列出父级的所有子级(ID ParentID模式)
- SQL递归函数列出父级的所有子级(ID ParentID模式)
- SQL 查询每个字段为null的记录
- SQL tree data struct(1): adjacency list (id, parentid)
- IS NULL和=NULL的区别(SQL)
- SQL中IS NOT NULL与!=NULL的区别
- 对GB28181的catalog的parentid的说明
- 一个表中通过parentId得到不同层的内容
- 查询值为null的记录
- mysql删除字段为null的记录
- mysql删除字段为null的记录
- SQL is NULL 和 = NULL区别
- 因为 setAdapter 返回的 null
- java直接跳出上层循环(多层循环)
- 权限系统普遍通性,以shrio为例
- 最新版Intellij IDEA插件JRebel 7.0.7安装与激活教程。
- 浏览器渲染ajax动态拼接元素样式失效问
- C#控制台程序,Winform,WPF的区别
- sql迭代 因为parentid is null 要有parentid为null的记录
- 有条件的debug断点
- spring mvc 扫描注解(ioc,di)
- SetWindowPos
- src与href区别
- spring 注入 动态注入
- windows mysql 5.7.18 解压版安装配置过程
- 生产者消费者之Java/python实现
- shrio动态修改权限,解决重启