技术栈

主页 > 数据库 >

case when else表达式分享

技术栈 - 中国领先的IT技术门户

case when else表达式分享


<!-- 按照条件查询活动,使用Activity类来接查询结果 -->  
    <select id="selectActivityDoPagination" parameterType="java.lang.String" resultMap="activity">  
      
        select  
        ID,  
        ACTIVITY_CODE,  
        ACTIVITY_NAME,  
        ACTIVITY_DESCRIPTION,  
        CASE(INDIRECT_RECOMMEND) WHEN '1' THEN '是' ELSE '否' END AS INDIRECT_RECOMMEND,  
        to_char(CREATE_TIME,'yyyy-mm-dd hh24:mi:ss')  CREATE_TIME,  
        to_char(LAST_MODIFIED,'yyyy-mm-dd hh24:mi:ss') LAST_MODIFIED,  
        BANNER_PATH   
        from  
          
        ACTIVITY  
          
        where 1=1  
          
        <if test="activity.activityCode  != null and activity.activityCode != ''">  
            and ACTIVITY_CODE=#{activity.activityCode}  
        </if>  
          
        <if test="activity.activityName != null and activity.activityName != ''">  
            and ACTIVITY_NAME=#{activity.activityName}  
        </if>  
          
        <if test="activity.indirectRecommend != null and activity.indirectRecommend != ''">  
            and INDIRECT_RECOMMEND=#{activity.indirectRecommend}  
        </if>  
          
        <if test="activity.createTime != null and activity.createTime != ''">  
            and TO_CHAR(CREATE_TIME,'YYYY-MM-DD') = '${activity.createTime}'   
        </if>  
          
        <if test="activity.lastModified != null and activity.lastModified != ''">  
            and TO_CHAR(LAST_MODIFIED,'YYYY-MM-DD') = '${activity.lastModified}'  
        </if>  
          
        order by ID asc  
    </select>  
责任编辑:admin  二维码分享:
本文标签: activity