mybatis复杂查询

 
<select id="getSubDeptIds" resultType="java.lang.Integer">
        select DISTINCT id from sys_dept
        where 1 = 0 or
        <foreach collection="deptIds" index="index" item="i" separator="OR">
            pid like CONCAT('%[',#{i},']%')
        </foreach>
        or
        <foreach collection="deptIds" index="index" item="i" separator="OR">
            id = #{i}
        </foreach>
    </select>

 

 

 

<select id="queryExport" resultType="HashMap" parameterType="student">
    select a.telephoneNumber,a.email,a.idNumber,a.userName,a.name,case when a.sex = 1 then '男' else '女' end sex,a.birthDay,b.provinceName,
    c.cityName,d.areaName,a.studentNumber,e.acdemyName,f.specialtyName,a.grade,h.className from t_student a
    left join t_province b on a.provinceId = b.provinceId
    left join t_city c  on a.cityId = c.cityId
    left join t_area d on a.areaId = d.areaId
    left join t_acdemy e on a.acdemyId = e.acdemyId
    left join t_specialty f on a.specialtyId = f.specialtyId
    left join t_trainingplan g on a.planId = g.planId
    left join t_class h on a.classId = h.classId
    where 1 = 1
    <if test="schoolId != null">
      and a.schoolId = #{schoolId}
    </if>
    <if test="idNumber != null" >
      and a.idNumber like concat('%',#{idNumber},'%')
    </if>
    <if test="name != null" >
      and a.name like concat('%',#{email},'%')
    </if>
    <if test="status != null" >
      and a.status = #{status,jdbcType=INTEGER}
    </if>
    <if test="acdemyId != null" >
      and a.acdemyId = #{acdemyId,jdbcType=BIGINT}
    </if>
    <if test="specialtyId != null" >
      and a.specialtyId = #{specialtyId,jdbcType=BIGINT}
    </if>
    <if test="grade != null" >
      and a.grade = #{grade,jdbcType=VARCHAR}
    </if>
    <if test="className != null" >
      and b.className like concat('%',#{className},'%')
    </if>
    order by a.grade desc,a.studentNumber asc
  </select>
 
 select <include refid="Base_Column_List" />
        FROM t_gslm order by CONVERT(name USING gbk);

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值