记录下犯的小错误,供大家参考下,有错欢迎指正!
在做模糊查询的时候出的问题
以下是源错误写法:
<select id="selectAll" resultMap="tblKmSamBlacklistMap">
select * from TBL_KM_SAM_BLACKLIST
<where>
<if test="query.samId != null and query.samId !=''">
and sam_id like “%”#{query.samId}“%”
</if>
</where>
插了下资料发现写法不对,需要用concat(‘%’,***,‘%’)这样
下面是正确写法:
<select id="selectAll" resultMap="tblKmSamBlacklistMap">
select * from TBL_KM_SAM_BLACKLIST
<where>
<if test="query.samId != null and query.samId !=''">
and sam_id like concat('%' ,#{query.samId}, '%')
</if>
</where>
仅供大家参考