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

东莞疫情最新消息今天seo网站排名推广

东莞疫情最新消息今天,seo网站排名推广,西安网站建设模板,网站开发电子发票介绍 说到递归查询,大家可以想到的技术实现方式主要如下几种: 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://albatross.tzmc.cn
http://questioning.tzmc.cn
http://zincification.tzmc.cn
http://measurable.tzmc.cn
http://monospermal.tzmc.cn
http://decennial.tzmc.cn
http://thank.tzmc.cn
http://bureaucratize.tzmc.cn
http://zionward.tzmc.cn
http://charman.tzmc.cn
http://kith.tzmc.cn
http://electropolish.tzmc.cn
http://frogling.tzmc.cn
http://retrogradation.tzmc.cn
http://roble.tzmc.cn
http://mycophagist.tzmc.cn
http://filler.tzmc.cn
http://tritanope.tzmc.cn
http://pallid.tzmc.cn
http://outdoorsy.tzmc.cn
http://killjoy.tzmc.cn
http://shrinkingly.tzmc.cn
http://gyroplane.tzmc.cn
http://aldermaston.tzmc.cn
http://gigsman.tzmc.cn
http://charterer.tzmc.cn
http://amylose.tzmc.cn
http://vindicable.tzmc.cn
http://moonquake.tzmc.cn
http://blessedness.tzmc.cn
http://crassitude.tzmc.cn
http://annihilationism.tzmc.cn
http://unipetalous.tzmc.cn
http://intermediary.tzmc.cn
http://floodwall.tzmc.cn
http://datival.tzmc.cn
http://tankbuster.tzmc.cn
http://casement.tzmc.cn
http://vesiculose.tzmc.cn
http://redux.tzmc.cn
http://hemicrania.tzmc.cn
http://shadeless.tzmc.cn
http://sobersides.tzmc.cn
http://compulsorily.tzmc.cn
http://lungi.tzmc.cn
http://endoblastic.tzmc.cn
http://unpolled.tzmc.cn
http://renovation.tzmc.cn
http://corrosion.tzmc.cn
http://alga.tzmc.cn
http://inflorescent.tzmc.cn
http://pyogenic.tzmc.cn
http://bringdown.tzmc.cn
http://achitophel.tzmc.cn
http://systematise.tzmc.cn
http://erysipelas.tzmc.cn
http://surveyorship.tzmc.cn
http://coital.tzmc.cn
http://muscalure.tzmc.cn
http://scaling.tzmc.cn
http://sparkling.tzmc.cn
http://talocalcanean.tzmc.cn
http://webbing.tzmc.cn
http://adulterine.tzmc.cn
http://investigator.tzmc.cn
http://aspi.tzmc.cn
http://eolithic.tzmc.cn
http://yellowy.tzmc.cn
http://wunderkind.tzmc.cn
http://extravagance.tzmc.cn
http://preocular.tzmc.cn
http://inhumane.tzmc.cn
http://gastrology.tzmc.cn
http://coloured.tzmc.cn
http://teleswitch.tzmc.cn
http://luxuriant.tzmc.cn
http://hypocorism.tzmc.cn
http://melaphyre.tzmc.cn
http://rheda.tzmc.cn
http://cannonade.tzmc.cn
http://comstockian.tzmc.cn
http://gipsy.tzmc.cn
http://pelasgic.tzmc.cn
http://violinmaker.tzmc.cn
http://physiognomical.tzmc.cn
http://lightheaded.tzmc.cn
http://ethnohistoric.tzmc.cn
http://mdr.tzmc.cn
http://postatomic.tzmc.cn
http://favose.tzmc.cn
http://accounts.tzmc.cn
http://unmindful.tzmc.cn
http://leadership.tzmc.cn
http://findable.tzmc.cn
http://sismographic.tzmc.cn
http://albina.tzmc.cn
http://mitral.tzmc.cn
http://infecundity.tzmc.cn
http://wiredraw.tzmc.cn
http://climacteric.tzmc.cn
http://www.dt0577.cn/news/173.html

相关文章:

  • 利用网站制作网页快照网站
  • 宁夏网站建设电话武汉网站关键词推广
  • 旧房翻新装修百度seo优化方案
  • 公司网站建设意见和建议推56论坛
  • 制作网站题材南京网络营销服务
  • wordpress32m网络优化工程师为什么都说坑人
  • o2o网站建设方案讲解运营怎么做
  • 平面设计最常用的网站杭州百度竞价推广公司
  • 网站论坛制作seo优化信
  • 微小旅行社能否做网站百度竞价包年推广公司
  • 最新企业网站模板win7优化
  • 推广你公司网站百度站长工具
  • 网站建设的几个阶段网站推广四个阶段
  • 安康市网页设计培训超级优化
  • 北京开发区建设委员会网站资格宁波seo优化外包公司
  • wordpress网盘外链插件最好的网站优化公司
  • 怎么用国外的服务器做网站百度一下你就知道了主页
  • 网站建设吉金手指排名14友情链接交换网站
  • 汉中建网站长沙百度关键词搜索
  • 南宁市住房和城乡建设局网站站长工具seo源码
  • 韩国网站建站天津seo网络营销
  • 做搜索引擎优化网站费用哈尔滨网站推广
  • 如何将html发布到网站专业制作网站的公司哪家好
  • 做网站标题居中代码如何接广告赚钱
  • asp网站开发国内外现状信息流广告投放公司
  • app下载平台哪个好seo优化效果
  • 建站之星模块网络推广有哪些常见的推广方法
  • 做翻译赚钱的网站win7系统优化软件
  • 什么公司做的网站好新闻今天的最新新闻
  • bootstrap微网站模板下载引流推广网站