zoukankan      html  css  js  c++  java
  • mybatis相关函数

    MyBatis中的if....else...表示方法

    <choose>
        <when test="">
            //...
        </when>
        <otherwise>
            //...
        </otherwise>
    </choose>

    其中choose为一个整体 
    when是if 
    otherwise是else

    示例:

    <select id="selectSelective" resultMap="xxx" parameterType="xxx">
        select
        <include refid="Base_Column_List"/>
        from xxx
        where del_flag=0
        <choose>
            <when test="xxx !=null and xxx != ''">
                and xxx like concat(concat('%', #{xxx}), '%')
            </when>
            <otherwise>
                and xxx like '**%'
            </otherwise>
        </choose>
    </select>

    MyBatis中的 case when 表示方法

    CASE WHEN condition THEN result
     
    [WHEN...THEN...]
     
    ELSE result
     
    END


    condition是一个返回布尔类型的表达式,如果表达式返回true,则整个函数返回相应result的值,如果表达式皆为false,则返回ElSE后result的值,如果省略了ELSE子句,则返回NULL。

    示例:

    SELECT
        STUDENT_NAME,
      (CASE WHEN score < 60 THEN '不及格'
            WHEN score >= 60 AND score < 80 THEN '及格'
            WHEN score >= 80 THEN '优秀'
            ELSE '异常' END) AS REMARK
    FROM TABLE
    

      

  • 相关阅读:
    对象拷贝-深拷贝
    eclipse安装桌面快捷方式
    ajax 分页
    单例模式
    过滤器
    ajax参数详解
    json
    反射
    jdbc02
    jdbc --例子7
  • 原文地址:https://www.cnblogs.com/tomingto/p/12759706.html
Copyright © 2011-2022 走看看