1. 动态sql之 <if> 标签
<select id="findAll" parameterType="queryVO" resultType="User">
select * from `user` where 1=1
<if test="user.id != 0">
and id=#{user.id}
</if>
<if test="user.username != null">
and username=#{user.username}
</if>
</select>
2. 动态sql之 <where> 标签
<select id="findAll" parameterType="queryVO" resultType="User">
select * from `user`
<where>
<if test="user.id != 0">
and id=#{user.id}
</if>
<if test="user.username != null">
and username=#{user.user