반응형
1. null 체크
<if test='id neq null and id neq ""'>
and table_name.id = #{id}
</if>
<if test='id != null and id neq ""'>
and table_name.id = #{id}
</if>
<if test='id != null and !"".equals(id)'>
and table_name.id = #{id}
</if>
2. 문자비교
<if test=" 'idName'.equals(id)">
and a.idName = #{id}
</if>
2. 문자열비교
<!-- equalsIgnoreCase -->
<if test=" 'code'.equalsIgnoreCase(id)">
and table_name.id = #{id}
</if>
<!-- == 연산자 사용 -->
<if test=" id == 'code'.toString()">
and table_name.id = #{id}
</if>
<!-- eq 사용 -->
<if test=" id eq 'code'.toString()">
and table_name.id = #{id}
</if>
반응형
'기술(technology) > Mybatis' 카테고리의 다른 글
org.mybatis.spring.MyBatisSystemException: (0) | 2021.08.20 |
---|---|
Mybatis choose문 문법 (if else) (0) | 2021.05.06 |
Mybatis 란? 장점,단점 사용하는 이유? (0) | 2021.03.31 |
Mybatis 부등호 >,<,>=,<= 안먹힐때 문법오류 대체방법 (0) | 2021.03.30 |
댓글