MyBatisの書き込みSQLステートメントを使用する場合は、パラメータの値に頻繁に遭遇する条件は、異なるフィールドを照会するためにここに要約を作成します:
<where>
<!-- 判断条件参数是否为空 -->
<if test="orgId != 'null' and orgId != ''">
and user.org_id = #{orgId}
</if>
<!-- 判断条件参数是否为某值 -->
<if test="searchCon == 'cn'">
and opxuser.name like CONCAT(#{searchCon},'%')
</if>
</where>
本明細書で使用する場合、
1 = 1がどこ裏に書かれている追加するよりもエレガント。