<!-- 3.if和where的使用-->
<sql id="select_user_where">
<if test="user != null">
<if test="user.sex != null and user.sex != ''">
sex = #{user.sex}
</if>
<if test="user.username != null and user.username != ''">
and username LIKE '%${user.username}%'
</if>
<if test="user.address != null and user.address != ''">
and address LIKE '%${user.address}%'
</if>
</if>
</sql>
<select id="findUserList" parameterType="userQueryVO" resultType="user">
/*性别和名字*/
SELECT * FROM user
<where>
<include refid="select_user_where"/>
</where>
</select>
