Mybatis 批量删除 单引号
Posted 山高我为峰
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Mybatis 批量删除 单引号相关的知识,希望对你有一定的参考价值。
mysql效果:
DELETE FROM attachment_table WHERE logid = ‘24‘ AND NAME IN (‘policycustom1.xmlx‘,‘policycustom.xmlx‘,‘policycustom1.xmlx‘,‘policycustom.xmlx‘);
Mybatis:
void deleteByLogIdAndNames(@Param("logid") Integer logID, @Param("names") String[] names);
<delete id="deleteByLogIdAndNames"> delete from attachment_table where logid = #{logid,jdbcType=INTEGER} AND NAME IN <foreach collection="names" item="item" index="index" open="(" close=")" separator=","> #{item, jdbcType=LONGVARCHAR} </foreach> </delete>
我开始是如下写:这种方式无法达到上面MySQL的效果
<delete id="deleteByLogIdAndNames"> delete from attachment_table where logid = #{logid,jdbcType=INTEGER} AND NAME IN <foreach collection="names" item="item" index="index" open="(" close=")" separator=","> #item </foreach> </delete>
以上是关于Mybatis 批量删除 单引号的主要内容,如果未能解决你的问题,请参考以下文章
mybatis的 if test 条件判断字符串单双引号解析问题