mybatis-find_in_set,查某个字段包含动态的参数,参数是数组

1, java接口类:

List<BdUserRegisterCompany> findByProductTypeAnd(@Param("typeIdArray") String[] typeIdArray,
                                                 @Param("industryArray") String[] industryArray);

2,mapper.xml:

SELECT t.NAME ,t.REGISTER_TYPE, t.MEMBER_CODE,t.USERID FROM bd_user_register t join bd_user_register_company c on t.USERID=c.register_id where 1=1
    <if test="typeIdArray != null and typeIdArray != ''">
        <foreach collection="typeIdArray" item="typeId" index="index"  >
            and find_in_set(#{typeId},c.product_type_sub)
        </foreach>
    </if>
collection="java方法的数组名" item="随便起的名字,遍历时的变量“ index="index"

函数 find_in_set(参数,字段名),应该相当于 字段c.product_type_sub 包含参数typeId,
比如字段值1000,10002,1223,234 参数是个数组1000,1223
那么就查出了一条,因为字段包含了这两个参数

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值