1、choose選擇判斷等于固定值
type 字段為字符型,直接寫<when test="params.type == '2'">是不會生效的,要把其轉為字符串后方可生效。正確寫法為<when test="params.type == '2'.toString()">
<choose>
<when test="params.type == '2'.toString()">
<if test="params.phoneNo != null and params.phoneNo != ''">
and a.phone_no like concat('%',#{params.phoneNo},'%')
</if>
</when>
<otherwise>
<if test="params.phoneNo != null and params.phoneNo != ''">
and u.phone_no like concat('%',#{params.phoneNo},'%')
</if>
</otherwise>
</choose>
2、不想寫大于小于轉義,可以用<![CDATA[<>]]>直接引入sql文本
3、like的寫法
<if test="params.userPhoneNo != null and params.userPhoneNo != ''">
and u.phone_no like concat('%',#{params.userPhoneNo},'%')
</if>