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>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM