水神骑士联盟吧 关注:4贴子:334
  • 0回复贴,共1

关于mybatis动态sql

只看楼主收藏回复

多条件查询:
<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关系词因为没有实际意义


IP属地:河北1楼2016-07-21 10:30回复