Mybatis传入参数字符串分割成数组作为条件遍历不用in不用in

<if test="typeIds != null and typeIds != ''">
        and
            <foreach collection="typeIds.split(',')" item="id" open="type_ids like concat(" separator=" and type_ids like concat(">
                '%', #{id}, '%')
            </foreach>
        </if>

<insert id="insertBatch">
    INSERT INTO tb_student (name, age, phone, address, class_id) VALUES
    <foreach collection="list" separator="," item="item">
        (#{item.name},#{item.age},#{item.phone},#{item.address},#{item.classId})
    </foreach>
  </insert>

    <update id="deleteNoticeById">
        update t_w_send_notice
        set
        is_deleted = 1
        where id in
        <foreach collection="idlist" item="item" index="index" 
        open="(" separator="," close=")">
            #{item}
        </foreach>
    </update>

    <select id="selectByIdList" resultType="com.ruoyi.project.wxb.entity.po.Notice">
        select t.id,t.user_id,t.start_time,t.content from t_w_send_notice t
        where is_deleted=0 and id in
        <foreach collection="list" item="item" index="index" 
        open="(" separator="," close=")">
            #{item}
        </foreach>
    </select>

 <select id="totalCount"  resultType="java.lang.Integer">
        select * from xxxx
        <where>
            <if test="bedNo!=null and bedNo!='' ">
                and  bed_no like  '%${bedNo}%'
            </if>
            <if test="bedRoomId!=null and bedRoomId!=''">
                and  bed_roomId like  '%${bedRoomId}%'
            </if>
        </where>
    </select>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

汤永红

一分也是爱

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值