<if test="userName != null" >
and user_name like concat('%', #{userName}, '%')
</if>
<if test="realName != null" >
and real_name like concat('%', #{realName}, '%')
</if>
本文深入探讨了MyBatis中if标签的使用,特别是在动态SQL构建过程中的灵活性和效率。通过示例展示了如何根据不同的参数动态地构建SQL查询语句,特别是当需要进行模糊查询时的处理技巧。
<if test="userName != null" >
and user_name like concat('%', #{userName}, '%')
</if>
<if test="realName != null" >
and real_name like concat('%', #{realName}, '%')
</if>
1898
1404
189
1627

被折叠的 条评论
为什么被折叠?