Mybatis 的foreach 可以嵌套吗

如题所述

可以
<select id="nestedSelect" parameterType="Parameter" resultType="map">
select *
from names
<where>
<foreach collection="names" item="name" separator="or">
<foreach collection="name.firstNames" item="firstName" separator="or">
(lastName = #{name.lastName} and firstName = #{firstName})
</foreach>
</foreach>
</where>
</select>
温馨提示:答案为网友推荐,仅供参考