728x90
반응형
if(name.equals("A") || name.equals("B")) 를 ibatis로 사용하고 싶은데요..
이 경우는 어쩔 수 없이,
< isEqual property="name" compareValue="A">
<isEqual property="name" compareValue="B">
...
</isEqual>
< /isEqual>
< isNotEqual property="name" compareValue="A">
<isEqual property="name" compareValue="B">
...
</isEqual>
</isNotEqual>
< isEqual property="name" compareValue="A">
<isNotEqual property="name" compareValue="B">
...
</isNotEqual>
</isEqual>
이런 식으로 세 가지 조건을 다 해줘야 할 것 같네요. 아니면 두 개가 중복되어도 상관없다면 그냥
<isEqual property="name" compareValue="A">
...
</isEqual>
< isEqual property="name" compareValue="B">
...
</isEqual>
와 같이 똑같은 조건으로 해도 되겠죠.
select *
from test
where 1 = 1
and 1 = 1
and 1 = 1
위와 같이 중복된다고 에러가 발생하지는 않으니까요.
도저히 감이 안잡히네요..
도움 좀 주세요..ㅜㅜ
아직까지 한 번도 or 조건으로 다이나믹쿼리를 만들 일이 없어서 생각도 못해봤는데...
이 경우는 어쩔 수 없이,
< isEqual property="name" compareValue="A">
<isEqual property="name" compareValue="B">
...
</isEqual>
< /isEqual>
< isNotEqual property="name" compareValue="A">
<isEqual property="name" compareValue="B">
...
</isEqual>
</isNotEqual>
< isEqual property="name" compareValue="A">
<isNotEqual property="name" compareValue="B">
...
</isNotEqual>
</isEqual>
이런 식으로 세 가지 조건을 다 해줘야 할 것 같네요. 아니면 두 개가 중복되어도 상관없다면 그냥
<isEqual property="name" compareValue="A">
...
</isEqual>
< isEqual property="name" compareValue="B">
...
</isEqual>
와 같이 똑같은 조건으로 해도 되겠죠.
select *
from test
where 1 = 1
and 1 = 1
and 1 = 1
위와 같이 중복된다고 에러가 발생하지는 않으니까요.
728x90
반응형
'SQL > IBATIS' 카테고리의 다른 글
java-ibatis-mssql, 소수점 문제 (0) | 2014.10.23 |
---|---|
ibatis selectkey 활용 (0) | 2014.10.17 |
ibatis - 동적으로 테이블 가져올 때 부적합한 열이름 에러 (0) | 2014.09.11 |
ibatis에서 queryForList와 queryForMap의 차이 (0) | 2014.08.21 |
ibatis Boolean 사용법 (0) | 2014.04.12 |
동적쿼리 예제 isGreater, isNull,isEmpty 등 (0) | 2014.04.12 |
ibatis 글자수로 조건 줄때 (0) | 2014.04.12 |
동적 SQL (0) | 2014.03.25 |