깜놀하는 해므찌로

Egov Spring Oracle Concat 오라클 문자열 합치기 예시 본문

IT

Egov Spring Oracle Concat 오라클 문자열 합치기 예시

agnusdei1207 2022. 7. 15. 10:01
반응형
SMALL

- 기본 구조

SELECT CONCAT('1234', '5678')
     , '1234' || '5678' 
  FROM DUAL

1. 둘 다 동일한 결과 '12345678' 출력

 

- 검색 응용

<if test="searchKeyword !=null and searchKeyword !=''">
    <if test="searchCondition !=null and searchCondition !='' and searchCondition ==0">
        AND (TS.TTL LIKE '%'||#{searchKeyword}||'%' OR TS.CTT like '%'||#{searchKeyword}||'%')
    </if>
    <if test="searchCondition !=null and searchCondition !='' and searchCondition ==1">
        AND TS.TTL LIKE '%'||#{searchKeyword}||'%'
    </if>
    <if test="searchCondition !=null and searchCondition !='' and searchCondition ==2">
        AND TS.CTT LIKE '%'||#{searchKeyword}||'%'
    </if>
</if>

1. 검색어가 들어올 경우 LIKE 조건 활용 시 변수 앞뒤에 '%' 가 필요

2. CONCAT 함수 대신 ' || ' 를 활용하여 간략하게 표기 가능

반응형
LIST