当前位置: 首页 > news >正文

做ppt的背景图片网站wordpress个人网站备案管理

做ppt的背景图片网站,wordpress个人网站备案管理,wordpress模板修改服务,最便宜的企业邮箱多少钱一年介绍 说到递归查询,大家可以想到的技术实现方式主要如下几种: 1、各种主流应用开发语言本身通过算法实现 2、各种数据库引擎自身提供的算法实现 本文提到主要是针对第二种和第一种的结合 主要技术栈 1、ORM:Mybatis 2、DB:MyS…

介绍

说到递归查询,大家可以想到的技术实现方式主要如下几种:
1、各种主流应用开发语言本身通过算法实现
2、各种数据库引擎自身提供的算法实现

本文提到主要是针对第二种和第一种的结合

主要技术栈

1、ORM:Mybatis
2、DB:MySQL
3、开发语言:Java

代码实现示例

方式一、Mybatis Mapper类实现代码示例如下


// dept_employee  员工和部门的关系表
// dept 部门信息表
// 根据员工编号查询其直属部门的所有下级部门节点
@Select({"<script>","with recursive child_dept as\n" +"(\n" +"select id, code,name,name as dept_structure\n" +"from dept\n" +"where id in (\n" +"select DISTINCT dept_id from dept_employee\n" +"where employee_id= #{employeeId} " +"<when test='type!=null'>","and type=#{type}\n" +"</when>"+")\n" +"union\n" +"select a.id,a.code ,a.name, concat(b.dept_structure, ' > ', a.name) as dept_structure\n" +"from child_dept as b\n" +"join dept as a on b.code=a.parent_code\n" +")\n" +"select DISTINCT id from child_dept;\t","</script>"})List<Long> queryAllChildDeptByEmployeeId(@Param("employeeId") Long employeeId,@Param("type") String type);

方式二、Mybatis+存储过程示例如下:

    // Mybatis Mapper类调用存储过程@Select("call queryAllChildDeptByEmployeeId(#{employeeId},#{type})")@Options(statementType = StatementType.CALLABLE)List<Long> queryAllChildDeptByEmployeeId(@Param("employeeId") Long employeeId, String type);
//存储过程示例
CREATE DEFINER=`test`@`%` PROCEDURE `queryAllChildDeptByEmployeeId`(IN employeeId bigint,IN type VARCHAR(10))
BEGIN
if type is  null or type ='' THENwith recursive child_dept as(select id, code,name,name as dept_structurefrom deptwhere id in (select DISTINCT dept_id from dept_employeewhere employee_id= employeeId )unionselect a.id,a.code ,a.name, concat(b.dept_structure, ' > ', a.name) as dept_structurefrom child_dept as bjoin dept as a on b.code=a.parent_code)select DISTINCT id from child_dept;
ELSEwith recursive child_dept as(select id, code,name,name as dept_structurefrom deptwhere id in (select DISTINCT dept_id from dept_employeewhere employee_id= employeeId and type=type)unionselect a.id,a.code ,a.name, concat(b.dept_structure, ' > ', a.name) as dept_structurefrom child_dept as bjoin dept as a on b.code=a.parent_code)select DISTINCT id from child_dept;	
END IF;										
END

踩坑介绍

以上实现方式涉及到了MySQL的with as 语法,此实现方式必须给予MySQL 8.0.x版本,5.x.x版本不支持,

解决方案:
1、升级数据库版本为8.x版本
2、采用5.x版本语法FIND_IN_SET,如下代码示例

SELECT au.id, au.name, au.pidFROM (SELECT * FROM dept WHERE pid IS NOT NULL) au,(SELECT @pid := '1002,1005') pdWHERE FIND_IN_SET(pid, @pid) > 0 and @pid := concat(@pid, ',', id)
UNION
SELECT id, name, pidFROM deptWHERE FIND_IN_SET(id, @pid) > 0ORDER BY id;  

3、采用应用开发语言实现,如Java代码实现

http://www.yayakq.cn/news/546022/

相关文章:

  • 网站开发的相关技术低价刷赞网站推广
  • 电子商务网站建设与维护题库电器 东莞网站建设
  • 上海公司网站网络工程考研考什么科目
  • 太原网站建设案例河南企业建站系统信息
  • 个人工商户做网站要上税吗wordpress覆盖安装
  • 石家庄网站建设seo公司清洁公司网站建设
  • 临沂做商城网站网页设计立项书怎么写
  • 传统网站建设团队建设网站需要什么资质吗
  • 自己如何做简单网站wordpress获取文章评论
  • 网站会员整合在线 wordpress
  • 网站服务器管理 硬件吉安知名网站建设
  • 免费建站系统腾讯云网站建设教程视频
  • qqip.探测网站建设手工品外贸出口网站建设方案
  • 诊断网站seo现状网址怎么申请网站
  • 嘉兴网站制作案例wordpress+改邮箱
  • asp网站制作设计教程开发新闻类网站
  • 12306网站 制作全flash 电子商务网站如何推广
  • 宣城 网站建设虚拟主机配置
  • 广州网站推广找哪里建湖网站开发
  • 快速seo整站优化排行买什么样的主机(用来建网站的)支持下载
  • 自己做网站打开是乱码邢台网站建设信息
  • 网站流量东莞沙田网站建设
  • 佛山个性化网站建设网页平台
  • 网站底部 设计用哪个程序做网站收录好
  • 网站做开票网络的基本概念
  • 手机网站开发 html5做自媒体哪家网站好
  • 建设优秀企业网站国外做水广告网站大全
  • 汕头做网站优化的公司资源丰富免费的网站推荐排名
  • 网站框架设计最大的设计公司
  • 网站主体负责人和网站负责人网站营销工作流程