查询树节点类型数据中的传参问题(如何将父表中没有的参数传给子查询)
子查询中如何传递参数问题
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.递归查询也要继续传参![需要继续传参](https://i-blog.csdnimg.cn/blog_migrate/c57fd625295438dae5e68b9885ac3d51.png)
3.递归中的SQL语句
另外:拼写不规范,该错两行泪!!!