mybatis模糊查询

来源:互联网 发布:千牛保证金是淘宝的吗 编辑:程序博客网 时间:2024/06/03 22:56

两种靠谱方法

第一种


      <if test="cond.name != null">        and a.name like concat(concat('%',#{cond.name, jdbcType=VARCHAR}),'%')      </if>

第二种

      <if test="cond.name != null and cond.name  != ''">        and a.name <if test="!strict"> like '%' ||</if><if test="strict"> = </if>#{cond.name, jdbcType=VARCHAR}<if test="!strict"> || '%' </if>      </if>

stric表示传入参数的属性

原创粉丝点击