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

建设网站有哪些目的是什么意思百度官网登录

建设网站有哪些目的是什么意思,百度官网登录,徐州市建设工程交易网,2345网址导航手机介绍 说到递归查询,大家可以想到的技术实现方式主要如下几种: 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.dinnco.com/news/81781.html

相关文章:

  • 营销网站优化seosem竞价推广托管
  • 微网站 域名百度网盘破解版
  • 衢州市建设工程质量监督站网站郑州seo教程
  • 回忆网站怎么做网络营销的工具有哪些
  • 淮北市11月30日疫情徐州seo排名公司
  • 有没有做武棍的网站网站策划是做什么的
  • 国内互联网前十名的公司网站的seo方案
  • pc网站转wap网站网站开发北京公司
  • 外贸网站建设工作室seo关键词推广渠道
  • 群晖 做网站 Java网站优化及推广方案
  • 免费下载ppt模板网站有哪些app网络推广方案
  • 电脑可以做网站服务器吗网站推广优化外链
  • 东山县建设局网站百度一级代理商
  • 宁波企业自助建站企业培训权威机构
  • 营销广告策划方案谷歌seo查询
  • 企业网站有什么功能网站seo思路
  • 做律师网站公司教育培训机构营销方案
  • asp.net 4.0网站开发与项目实战兰州网络seo
  • 汽车行业网站设计培训网
  • 网站设计模板 优帮云seo运营学校
  • 网站建设论文结尾网络推广外包内容
  • 做黑彩网站赚钱吗个人信息怎么在百度推广
  • 网站公司后台seo推广优化排名软件
  • 网页制作软件是哪个百度seo指南
  • 做电子商城网站网页制作软件免费版
  • idc数据中心排名百度关键词在线优化
  • 做视频网站成本百度竞价规则
  • 别人带做的网站关闭了权限咋办seo排名技术教程
  • 苏州餐饮 网站建设谷歌引擎搜索
  • 网站建设样式百度平台app