mybatis中xml开发like的几种写法
程序员文章站
2022-06-03 09:46:51
...
方法1:concat
<where>
<trim suffixOverrides="," >
<if test="id != null and id != ''" >
and id = #{id}
</if>
<if test="name != null and name != ''" >
and name like concat('%',#{name},'%')
</if>
</trim>
</where>
方法2:${}
<if test="examTypeName!=null and examTypeName!=''">
and exam_type_name like '%${examTypeName}%'
</if>
方法3:#{}
<if test="examTypeName!=null and examTypeName!=''">
and exam_type_name like "%"#{examTypeName}"%"
</if>
上一篇: 对视频编辑APP 时间轴界面的认识