like查询的用法
<if test="params.name != null and params.name != ''">
<bind name="likeName" value="'%' + params.name + '%'"/>
</if>
<if test="taskProperties != null and taskProperties != ''">
and task_properties like concat ('%',#{taskProperties},'%')
</if>
集合in的用法
<!-- 集合 -->
<if test="step != null">
AND TKD.ISTEP in
<foreach item="itm" collection="step" separator="," open="(" close=")" index="index">
#{itm, jdbcType=INTEGER}
</foreach>
</if>
<!-- 字符串用逗号分割 -->
<foreach item="itm" collection="userCategory.split(',')" separator="," open="(" close=")" index="index">
#{itm, jdbcType=INTEGER}
</foreach>
条件判断
<choose>
<when test="pPkList != null and pPkList.size > 0">
lit.pk_examlist PK_LIST,
lit.vname as list_name,
nvl((select sum(v1.list_2_weight / 100 * v1.result_score)
from v_qg_examtask v1
where v1.pk_examobj = lit.pk_examobj
and v1.pk_examlist = lit.pk_examlist
and v1.iyear = v.iyear),
0.0) score
</when>
<when test="bPkList != null and bPkList.size > 0">
litb.pk_examlist_b PK_LIST,
litb.vname as list_name,
nvl(v.result_score,0.0) score
</when>
</choose>
union all的用法及sql嵌套,此方法支持MyBatis-Plus的分页功能,重点是最后的别名t
<sql id="getHzListBaseColumnsList">
ID, NAME, CREATE_TIME, CREATE_NAME, CREATE_BY
</sql>
<select id="getHzList" resultType="xxx.modules.vo.HzVo">
select *
from (
select <include refid="getHzListBaseColumnsList" />
from rs_tar_r_lwbb
where BPM_STATUS = 6
and DEL = 0
union all
select <include refid="getHzListBaseColumnsList" />
from rs_tar_r_xcp
where BPM_STATUS = 6
and DEL = 0
union all
select <include refid="getHzListBaseColumnsList" />
from rs_tar_r_zzyz
where BPM_STATUS = 6
and DEL = 0
) t
</select>
# To Be Continued!😎
← Mysql优化和性能 Minio部署及配置 →