Mybatis进行多条件查询值trim标签
1.trim 若标签中有内容时:
prefix/suffix:将trim标签中内容前面或后面添加指定内容
suffixOverride/prefixOverride:将trim标签中内容前面或后面添加指定内容删除
若标签中没有内容时,trim标签也没有任何效果
<!--List<Emp> getEmpByCondition(Emp emp);-->
<select id="getEmpByCondition" resultType="emp">
select * from t_emp
<trim prefix="where" prefixOverrides="" suffixOverrides="and">
<if test="empName!=null and empName !=''">
emp_name=#{empName} and
</if>
<if test="age!=null and age !=''">
age=#{age}
</if>
<if test="sex!=null and sex !=''">
sex=#{sex}
</if>
<if test="email!=null and email !=''">
email=#{email}
</if>
</trim>
</select>
