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

信用网站建设意义seo研究中心倒闭

信用网站建设意义,seo研究中心倒闭,深圳网站开发公司h5,网站建设入驻介绍 说到递归查询,大家可以想到的技术实现方式主要如下几种: 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.hkea.cn/news/365391/

相关文章:

  • 南宁网站建设制作后台网站关键词优化价格
  • 微信小程序商城制作公司宁波seo推广服务
  • 响应式购物网站公司seo是什么意思
  • 360未经证实的网站如何做电商运营方案
  • 网站建设类公司排名营销方案范文100例
  • 郑州网站设计 郑州网站开发网络优化有前途吗
  • 黑河做网站首页关键词排名优化
  • 网站二级域名怎么解析公司网络搭建
  • wordpress做网店win10优化大师是官方的吗
  • 弄个做网站公司产品宣传
  • 商品房建设信息网站googleplay商店
  • 菏泽 网站建设优化工具箱
  • 网站建设找哪家公司百度搜索热度
  • 网页设计论文引言北海百度seo
  • 网站空间哪家做的好网络营销的常用工具
  • 网站开发具体问题优化营商环境
  • wordpress4.5 火车头廊坊seo培训
  • 怎么做多个网站单点登录艺考培训
  • 网站怎么做双语种seo关键词如何设置
  • 用java做的游戏下载网站有哪些内容成都网络推广优化
  • 慈溪市网站建设google官网
  • 网站建设计划seo网站排名优化软件是什么
  • 大连网站建设谁家好郴州网站定制
  • 网站建设背景怎么写一个企业该如何进行网络营销
  • 为女朋友做的表白网站百度大数据分析工具
  • 上海高端网站建设服务公seo推广公司
  • 找人合伙做网站平台仿站定制模板建站
  • 深圳市网站建设科技公司腾讯网网站网址
  • wordpress语言文件夹seo销售好做吗
  • 河北建设集团官网西安网站seo