깜놀하는 해므찌로

MyBatis MariaDB MySQL 검색 SQL 문 / 검색 SELECT 문 예시 / UPPER LOWER 본문

IT

MyBatis MariaDB MySQL 검색 SQL 문 / 검색 SELECT 문 예시 / UPPER LOWER

agnusdei1207 2022. 7. 12. 09:24
반응형
SMALL
<sql id="Where">
    <if test="searchKeyword !=null and searchKeyword !=''">
        <if test="searchCondition !=null and searchCondition !='' and searchCondition ==0">
            AND (UPPER(AUTH_CODE) LIKE CONCAT('%',UPPER(#{searchKeyword}),'%') OR UPPER(AUTH_CODE_NM) like CONCAT('%',UPPER(#{searchKeyword}),'%'))
        </if>
        <if test="searchCondition !=null and searchCondition !='' and searchCondition ==1">
            AND UPPER(AUTH_CODE) LIKE CONCAT('%',UPPER(#{searchKeyword}),'%')
        </if>
        <if test="searchCondition !=null and searchCondition !='' and searchCondition ==2">
            AND UPPER(AUTH_CODE_NM) LIKE CONCAT('%',UPPER(#{searchKeyword}),'%')
        </if>
    </if>
</sql>

1. 대소문자 구분 없이 검색을 하기 위해 검색어 및 검색 대상 UPPER 함수 처리

2. 전체 (제목 + 내용) / 제목 / 내용 구분

반응형
LIST