1岩睁、choose選擇判斷等于固定值
type 字段為字符型暂筝,直接寫<when test="params.type == '2'">是不會生效的搪柑,要把其轉(zhuǎn)為字符串后方可生效薄腻。正確寫法為<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、不想寫大于小于轉(zhuǎn)義棉姐,可以用<![CDATA[<>]]>直接引入sql文本
3屠列、like的寫法
<if test="params.userPhoneNo != null and params.userPhoneNo != ''">
and u.phone_no like concat('%',#{params.userPhoneNo},'%')
</if>