多条件查询:
<select id="findAll" parameterType="map" resultMap="person">
select pId,pName from t_person
<where>
<if test="id != null">
pId = #{id}
</if>
<if test="name != null">
and pName = #{name}
</if>
</where>
</select>
if标签中判断语句前的and 或者 or,在前一个if标签为true时才起作用,所以第一个if标签可以不带and或者or关系词因为没有实际意义
<select id="findAll" parameterType="map" resultMap="person">
select pId,pName from t_person
<where>
<if test="id != null">
pId = #{id}
</if>
<if test="name != null">
and pName = #{name}
</if>
</where>
</select>
if标签中判断语句前的and 或者 or,在前一个if标签为true时才起作用,所以第一个if标签可以不带and或者or关系词因为没有实际意义