子查询中如何传递参数问题

查询树节点类型数据中的传参问题(如何将父表中没有的参数传给子查询)

子查询中如何传递参数问题

1.传入的参数用#{}括起来
  如:#{termCode} termCode, #{termNum} termNum

上代码

<resultMap type="com.zonekey.cmsm.entity.Tree" id="areaData">
    <result property="id" column="id"/>
    <result property="code" column="code"/>
    <result property="termCode" column="termCode"/>
    <result property="termNum" column="termNum"/>
    <association property="nodes" column="{id=id,code=code,termCode=termCode,termNum=termNum}" select="getAreaDatas"/>
    <association property="videoStreams" column="id" select="getVideoStreams"/>
</resultMap>
<select id="findCurriculum" parameterType="string" resultMap="areaData">
    select
		'1' id,name title,'N' attribute,code,'' sort,deptid, #{termCode} termCode, #{termNum} termNum
    from
		zonekey_school
	where
		code = #{code}
	limit 1
</select>
<select id="getAreaDatas" resultMap="areaData">
    select
    a.id,a.name title,a.attribute,a.sort,a.innerid,a.code,abc.subject AS subject,abc.id AS subjectId,#{termCode} termCode, #{termNum} termNum
    from
    zonekey_area a,zonekey_device d, zonekey_curriculum_${termCode}_${termNum} abc
    where
    a.deleteflag='0' and a.parentid =#{id} and a.code =#{code} and d.deleteflag='0' and d.typeid != 'B1' and
    d.typeid != '9'
    and case when a.attribute = 'Y' then d.areaid = a.id and a.id = abc.areaid AND abc.deleteflag = '0'
    AND abc.date = CURDATE()
    AND abc.endtime >= CURTIME()
    AND CURTIME() >= abc.starttime
    else 1=1 end
    group by a.id
    order by case when a.sort is null then -1 end ,a.sort ,a.innerid asc
</select>
2.递归查询也要继续传参需要继续传参
3.递归中的SQL语句

继续传参
另外:拼写不规范,该错两行泪!!!

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值