原先查询片段如下,自动生成的代码默认只能全字段匹配查询
<if test="hobby != null and hobby != ‘‘"> and HOBBY = #{hobby} </if> <if test="code != null and code != ‘‘"> and CODE = #{code} </if>
现要对code字段的值实现模糊查询,如下
<if test="hobby != null and hobby != ‘‘"> and HOBBY = #{hobby} </if> <if test="code != null and code != ‘‘"> and CODE like concat(concat(‘%‘,#{code}),‘%‘) </if>