Mybatis框架中有需要的对sql语句灵活拼接时,利用动态sql
在mapper.xml中添加代码:
在mapper.xml中添加代码:
Mybatis框架中有需要的对sql语句灵活拼接时,利用动态sql
在mapper.xml中添加代码:
<!-- 用户信息的综合查询 -->
<select id="findUserList" parameterType="dancheng.mybatis.po.UserQueryVo"
resultType="dancheng.mybatis.po.UserCustom">
SELECT * FROM USER
<where>
<if test="userCustom!=null">
<if test="userCustom.sex!=null and userCustom.sex!=''">
and user.sex = #{userCustom.sex}
</if>
<if test="userCustom.username!=null and userCustom.username!=''">
and user.username LIKE '%${userCustom.username}%'
</if>
</if>
</where>
</select>