편집 기록

편집 기록
  • 프로필 허대영(소프트웨어융합대학)님의 편집
    날짜2016.06.20

    mysql 질문입니다..


     <select id="languageList" parameterType="java.util.HashMap" resultType="java.util.HashMap">
        select bs.* 
          from (
            select 
            @rownum:=@rownum+1  as row_num 
                        ,go_code
                        , go_name
                        , co_code
                        , co_name1
                        , co_name2
                        , langGbn
                        , cnt
    
            from (
                    select 
                        go_code
                        , go_name
                        , co_code
                        , co_name1
                        , co_name2
                        , a.langGbn
                        , ifnull(cnt,0) as cnt
                    from (
                        select 
                            go_code
                            , go_name
                            , co_code
                            , co_name1
                            , co_name2
                            , langGbn
                            , langSort
                        from ts_gov_code a, (
                            select 
                                a.co_code 
                                , ifnull(b.co_name,a.co_name) as co_name1
                                , a.co_name as co_name2
                            from ts_code a
                            left join ts_code b on a.co_up_code=b.co_code
                            where a.co_up_code like 'ST%'
                            and a.co_val1 != 'type'
                            and a.co_code not in ('ST01','ST02')
                            <if test="type_code != null and type_code != '' ">
                            and a.co_code like concat(#{type_code},'%')
                            </if>
                        ) b
                        , (
                            select '한' as langGbn, 1 langSort 
                            union 
                            select '한.영' as langGbn, 2 langSort
                            union 
                            select '한.중' as langGbn, 3 langSort 
                            union 
                            select '한.일' as langGbn, 4 langSort
                            union 
                            select '한.영.중' as langGbn, 5 langSort
                            union 
                            select '한.영.일' as langGbn, 6 langSort 
                            union 
                            select '한.중.일' as langGbn, 7 langSort
                            union 
                            select '한.영.중.일' as langGbn, 8 langSort
                        ) c
                        where a.go_use_yn = 'Y' 
                        <if test="(go_code != null and go_code != '') or go_code == '36' ">
                            <if test="go_code != '36'">
                        and a.go_gbn = 'G'
                            </if>   
                        and substr(a.go_code,1,2) = #{go_code} 
                        </if>
                        <if test="(go_code == null or go_code == '') and go_code != '36' ">
                        and a.go_gbn = 'S'
                        </if>   
                    ) a 
                    left join (
                        select 
                            <if test="(go_code != null and go_code != '') or go_code == '36' "> 
                            si_go_code
                            </if>
                            <if test="(go_code == null or go_code == '') and go_code != '36' ">
                            substr(si_go_code,1,2) as si_go_code
                            </if>
                            , si_type_code
                            , langGbn
                            , count(*) as cnt
                        from (
                            select
                                si_go_code
                                , si_type_code
                                , case when si_ko_yn = 'Y' and si_en_yn != 'Y' and si_ch_yn != 'Y' and si_jp_yn != 'Y' then '한'
                                    when si_ko_yn = 'Y' and si_en_yn = 'Y' and si_ch_yn != 'Y' and si_jp_yn != 'Y' then '한.영'
                                    when si_ko_yn = 'Y' and si_en_yn !='Y' and si_ch_yn = 'Y' and si_jp_yn != 'Y' then '한.중'
                                    when si_ko_yn = 'Y' and si_en_yn != 'Y' and si_ch_yn != 'Y' and si_jp_yn = 'Y' then '한.일' 
                                    when si_ko_yn = 'Y' and si_en_yn = 'Y' and si_ch_yn = 'Y' and si_jp_yn != 'Y' then '한.영.중'
                                    when si_ko_yn = 'Y' and si_en_yn = 'Y' and si_ch_yn != 'Y' and si_jp_yn = 'Y' then '한.영.일'
                                    when si_ko_yn = 'Y' and si_en_yn != 'Y' and si_ch_yn = 'Y' and si_jp_yn = 'Y' then '한.중.일'
                                    when si_ko_yn = 'Y' and si_en_yn = 'Y' and si_ch_yn = 'Y' and si_jp_yn = 'Y' then '한.영.일.중'
                                    else '기타' end langGbn
                              from ts_sign
                              where si_del_yn != 'Y'
                              <if test="type_code != null and type_code != '' ">
                              and si_type_code like concat(#{type_code},'%')
                              </if>
                              <if test="(go_code != null and go_code != '') or go_code == '36' ">
                              and substr(si_go_code,1,2) = #{go_code}
                              </if>
                        ) sub
                        <if test="(go_code != null and go_code != '') or go_code == '36' ">
                        group by si_go_code, si_type_code, langGbn
                        </if>
                        <if test="(go_code == null or go_code == '') and go_code != '36' ">
                        group by substr(si_go_code,1,2), si_type_code, langGbn
                        </if>                   
                    ) b on b.si_go_code=a.go_code and b.si_type_code=a.co_code and b.langGbn=a.langGbn
                    order by go_code desc, co_code desc, langSort desc
                ) tt,  (select @rownum:=0) tmp
            ) bs
    
             order by row_num desc
             limit #{from_record},#{page_size}
    
            <!-- <![CDATA[
            where rownum < #{from_record} + #{page_size} + 1
            ]]>
        ) 
        where rnum > #{from_record} -->
        </select>
    

    위와같이 xml 맵퍼 sql 문중

    select '한' as langGbn, 1 langSort 
                            union 
                            select '한.영' as langGbn, 2 langSort
                            union 
                            select '한.중' as langGbn, 3 langSort 
                            union 
                            select '한.일' as langGbn, 4 langSort
                            union 
                            select '한.영.중' as langGbn, 5 langSort
                            union 
                            select '한.영.일' as langGbn, 6 langSort 
                            union 
                            select '한.중.일' as langGbn, 7 langSort
                            union 
                            select '한.영.중.일' as langGbn, 8 langSort
    

    이부분을 받아서 웹상에 출력하면 한글이 깨지는 현상이 발생합니다.ㅜ 영어는 잘 출력되고요 ㅜ

    �븳
    �븳.�쁺
    ....
    ....
    

    인코딩은 다 UTF-8 로 했고요 ㅜ

  • 프로필 김영광님의 편집
    날짜2016.06.20

    mysql 질문입니다..


    select bs.* from ( select @rownum:=@rownum+1 as row_num ,go_code , go_name , co_code , co_name1 , co_name2 , langGbn , cnt

        from (
                select 
                    go_code
                    , go_name
                    , co_code
                    , co_name1
                    , co_name2
                    , a.langGbn
                    , ifnull(cnt,0) as cnt
                from (
                    select 
                        go_code
                        , go_name
                        , co_code
                        , co_name1
                        , co_name2
                        , langGbn
                        , langSort
                    from ts_gov_code a, (
                        select 
                            a.co_code 
                            , ifnull(b.co_name,a.co_name) as co_name1
                            , a.co_name as co_name2
                        from ts_code a
                        left join ts_code b on a.co_up_code=b.co_code
                        where a.co_up_code like 'ST%'
                        and a.co_val1 != 'type'
                        and a.co_code not in ('ST01','ST02')
                        <if test="type_code != null and type_code != '' ">
                        and a.co_code like concat(#{type_code},'%')
                        </if>
                    ) b
                    , (
                        select '한' as langGbn, 1 langSort 
                        union 
                        select '한.영' as langGbn, 2 langSort
                        union 
                        select '한.중' as langGbn, 3 langSort 
                        union 
                        select '한.일' as langGbn, 4 langSort
                        union 
                        select '한.영.중' as langGbn, 5 langSort
                        union 
                        select '한.영.일' as langGbn, 6 langSort 
                        union 
                        select '한.중.일' as langGbn, 7 langSort
                        union 
                        select '한.영.중.일' as langGbn, 8 langSort
                    ) c
                    where a.go_use_yn = 'Y' 
                    <if test="(go_code != null and go_code != '') or go_code == '36' ">
                        <if test="go_code != '36'">
                    and a.go_gbn = 'G'
                        </if>   
                    and substr(a.go_code,1,2) = #{go_code} 
                    </if>
                    <if test="(go_code == null or go_code == '') and go_code != '36' ">
                    and a.go_gbn = 'S'
                    </if>   
                ) a 
                left join (
                    select 
                        <if test="(go_code != null and go_code != '') or go_code == '36' "> 
                        si_go_code
                        </if>
                        <if test="(go_code == null or go_code == '') and go_code != '36' ">
                        substr(si_go_code,1,2) as si_go_code
                        </if>
                        , si_type_code
                        , langGbn
                        , count(*) as cnt
                    from (
                        select
                            si_go_code
                            , si_type_code
                            , case when si_ko_yn = 'Y' and si_en_yn != 'Y' and si_ch_yn != 'Y' and si_jp_yn != 'Y' then '한'
                                when si_ko_yn = 'Y' and si_en_yn = 'Y' and si_ch_yn != 'Y' and si_jp_yn != 'Y' then '한.영'
                                when si_ko_yn = 'Y' and si_en_yn !='Y' and si_ch_yn = 'Y' and si_jp_yn != 'Y' then '한.중'
                                when si_ko_yn = 'Y' and si_en_yn != 'Y' and si_ch_yn != 'Y' and si_jp_yn = 'Y' then '한.일' 
                                when si_ko_yn = 'Y' and si_en_yn = 'Y' and si_ch_yn = 'Y' and si_jp_yn != 'Y' then '한.영.중'
                                when si_ko_yn = 'Y' and si_en_yn = 'Y' and si_ch_yn != 'Y' and si_jp_yn = 'Y' then '한.영.일'
                                when si_ko_yn = 'Y' and si_en_yn != 'Y' and si_ch_yn = 'Y' and si_jp_yn = 'Y' then '한.중.일'
                                when si_ko_yn = 'Y' and si_en_yn = 'Y' and si_ch_yn = 'Y' and si_jp_yn = 'Y' then '한.영.일.중'
                                else '기타' end langGbn
                          from ts_sign
                          where si_del_yn != 'Y'
                          <if test="type_code != null and type_code != '' ">
                          and si_type_code like concat(#{type_code},'%')
                          </if>
                          <if test="(go_code != null and go_code != '') or go_code == '36' ">
                          and substr(si_go_code,1,2) = #{go_code}
                          </if>
                    ) sub
                    <if test="(go_code != null and go_code != '') or go_code == '36' ">
                    group by si_go_code, si_type_code, langGbn
                    </if>
                    <if test="(go_code == null or go_code == '') and go_code != '36' ">
                    group by substr(si_go_code,1,2), si_type_code, langGbn
                    </if>                   
                ) b on b.si_go_code=a.go_code and b.si_type_code=a.co_code and b.langGbn=a.langGbn
                order by go_code desc, co_code desc, langSort desc
            ) tt,  (select @rownum:=0) tmp
        ) bs
    
         order by row_num desc
         limit #{from_record},#{page_size}
    
        <!-- <![CDATA[
        where rownum < #{from_record} + #{page_size} + 1
        ]]>
    ) 
    where rnum > #{from_record} -->
    </select>
    

    위와같이 xml 맵퍼 sql 문중

    select '한' as langGbn, 1 langSort union select '한.영' as langGbn, 2 langSort union select '한.중' as langGbn, 3 langSort union select '한.일' as langGbn, 4 langSort union select '한.영.중' as langGbn, 5 langSort union select '한.영.일' as langGbn, 6 langSort union select '한.중.일' as langGbn, 7 langSort union select '한.영.중.일' as langGbn, 8 langSort

    이부분을 받아서 웹상에 출력하면 한글이 깨지는 현상이 발생합니다.ㅜ 영어는 잘 출력되고요 ㅜ

    �븳 �븳.�쁺 .... ....

    인코딩은 다 UTF-8 로 했고요 ㅜ