1、场景
查询sql A的条件需要依靠另外一个查询sql B的结果,这时候就需要将B的结果动态拼接成in的形式,当然是有就拼,没有就不拼
举例: select * from A where 1=1 and A.a1 in ('B.b1','B.b2','B.b3' .....)
2、Mybits实现
mapper.jar
List<test> queryTest( @Param("list") List<InstanceNodeRecipient> sysCode);
XML 中
<if test="list !=null " >
<if test="list.size != 0 " >
AND t.userName in
<foreach collection="list" item="userCode"
index="index" open="(" close=")" separator=",">
#{userCode.user}
</foreach>
</if>
</if>