db2数据库递归查询

DB2数据库
<select id="selectOrgId" resultType="java.lang.String" parameterType="org.yatop.sysManage.userManage.info.SysUser">
        WITH RPL (ORG_ID,F_ORG_ID,ORG_NM) AS 
        (SELECT ORG_ID,F_ORG_ID,ORG_NM FROM SYS_ORG WHERE ORG_ID = #{orgId,jdbcType=VARCHAR}
          UNION ALL 
          SELECT child.ORG_ID,child.F_ORG_ID,child.ORG_NM FROM RPL parent,SYS_ORG child WHERE parent.ORG_ID=child.F_ORG_ID
        )
        SELECT * FROM RPL
    </select>

 

posted on 2017-07-26 10:23  火玉  阅读(679)  评论(0编辑  收藏  举报