<select id="getMaxDepartId" parameterType="java.lang.String" resultType="java.lang.String">
SELECT MAX(DEPART_ID) FROM T_P_DEPART
<where>
<if test="_parameter!=null and _parameter!=''">
AND DEPART_PID = #{departId,jdbcType=VARCHAR}
</if>
<if test="_parameter==null or _parameter==''">
AND DEPART_PID IS NULL
</if>
</where>
</select>
参数为pojo , if test读取该参数代码
<select id="findShopByName" parameterType="ShopVo" resultType="ShopCustomer">
select * from shop
<where>
<if test="shopCustomer.shopname!=null and shopCustomer.shopname!=''">
shop.shopname like '%${shopCustomer.shopname}%'
</if>
<if test="shopCustomer.shopname==null or shopCustomer.shopname==''">
AND shop.shopname is null
</if>
</where>
</select>
补充:关于mybatis中 if test的条件怎么写 1.mybatis 中 的 if test写法 1.1官方文档上对于if是这么写的
<if test="title != null">
AND title like #{title}
</if>