sql中对查询出的某个字段转换查询

 

    <select id="queryCmonByLanId" parameterType="java.util.Map" resultType="java.util.Map">
            SELECT     t.REGION_NAME,
                case t.REGION_TYPE
                WHEN '1400' then    (SELECT c.PAR_REGION_ID FROM common_region c where c.COMMON_REGION_ID = t.COMMON_REGION_ID)    
                when '1300' then t.COMMON_REGION_ID
                when '1100' then t.COMMON_REGION_ID
                else t.COMMON_REGION_ID
                END as REGION_ID,
                
                case t.REGION_TYPE
                WHEN '1400' then    (SELECT d.PAR_REGION_ID FROM common_region d where d.COMMON_REGION_ID = t.PAR_REGION_ID)    
                when '1300' then (SELECT e.PAR_REGION_ID FROM common_region e where e.COMMON_REGION_ID = t.COMMON_REGION_ID)
                when '1100' then t.COMMON_REGION_ID
                else t.COMMON_REGION_ID
                END as PROV_REGION
                
            from common_region t  where t.REGION_NBR = #{lanId}
            and t.STATUS_CD = '1000'
    </select>

posted @ 2019-06-27 14:25  戈博折刀  阅读(1718)  评论(0编辑  收藏  举报