<!-- 1:后面跟1=1 决对成立-->
<select id="queryPersonByidAndNo">
select * from person where 1=1
<if test=" id !=null and id !='' ">
and id = #{id}
</if>
<if test=" id !=null and id !='' ">
and no = #{no}
</if>
</select>
<!-- 2 :后面跟where标签,会将第一个and过滤(不会过滤第二个)-->
<select id="queryPersonByidAndNo">
select * from person where
<where>
<if test=" id !=null and id !='' ">
and id = #{id}
</if>
<if test=" id !=null and id !='' ">
and no = #{no}
</if>
</where>
</select>