mybatis的xml中sql语句中in的写法

mybatis的xml中sql语句中in的写法

问题描述:查询条件在List中

下面为实例


Boolean updateBillsToPay(@Param("BillIds") List BillIds);
<update id="updateBillsToPay" >
        UPDATE
        property_bill
        SET
        settle = 1
        WHERE
        id in
        <foreach  item="item" collection="BillIds" index="index"  open="(" separator="," close=")">
            #{item}
        </foreach>
    </update>

foreach元素的属性主要有 item,index,collection,open,separator,close。

# item表示集合中每一个元素进行迭代时的别名.
# index指 定一个名字,用于表示在迭代过程中,每次迭代到的位置.
# collection 为传进来的collection参数的 *类型*
# open表示该语句以什么开始
# separator表示在每次进行迭代之间以什么符号作为分隔符
# close表示以什么结束

你可能感兴趣的:(mybatis的xml中sql语句中in的写法)