sql使用查询in报错超出一千条处理

方法1
直接在业务逻辑上处理解决超出一千条数据的问题

方法2
SQL解决
中间一条优化了 使用iftest进行优化拼接

 <select id="queryHealthNotReport" resultType="org.jeecg.modules.epidemic.entity.NotReportUser">
        select s.id, s.username, s.realname, s.phone ,s.sex,s.user_identity from sys_user s, sys_user_depart d where s.id=d.user_id
        and s.status=1
        <if test="notReportUser.username != null">
            and s.username= #{notReportUser.username}
        </if>

        <if test="notReportUser.userIdentity != null">
            and  s.user_identity = #{notReportUser.userIdentity}
        </if>
        <if test="notReportUser.realname != null">
            and  s.realname like concat('%',#{notReportUser.realname},'%')
        </if>
        and d.dep_id in
        <foreach collection="deptIds" open="(" close=")" separator="," item="deptId" index="index">
            <if test="(index % 999) == 998">
             NULL) OR d.dep_id IN(
            </if>
         #{deptId}
        </foreach>
        <if test="reportedUserIds != null and reportedUserIds.size > 0">
            and s.username not in
            <foreach collection="reportedUserIds" open="(" close=")" separator="," item="reportedUserId">
                #{reportedUserId}
            </foreach>
        </if>
    </select>
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值