1.

<if test="keyword!=null and keyword!=''">
AND (m.matnr LIKE concat('%',#{keyword,jdbcType=VARCHAR},'%')
OR m.maktx LIKE concat('%',#{keyword,jdbcType=VARCHAR},'%')
OR ub.barcode LIKE concat('%',#{keyword,jdbcType=VARCHAR},'%')
OR uc.barcode LIKE concat('%',#{keyword,jdbcType=VARCHAR},'%')
OR uf.barcode LIKE concat('%',#{keyword,jdbcType=VARCHAR},'%')
OR m.`type` LIKE concat('%',#{keyword,jdbcType=VARCHAR},'%')
OR t.`name` LIKE concat('%',#{keyword,jdbcType=VARCHAR},'%')
OR m.`kondm` LIKE concat('%',#{keyword,jdbcType=VARCHAR},'%')
OR b.`name` LIKE concat('%',#{keyword,jdbcType=VARCHAR},'%')
OR f.`row_id` LIKE concat('%',#{keyword,jdbcType=VARCHAR},'%')
OR f.`name` LIKE concat('%',#{keyword,jdbcType=VARCHAR},'%')
)
</if>

2.
<if test="pBrandName != null and pBrandName.trim() != ''">
<bind name="pBrandName" value="'%' + pBrandName + '%'"/>
and (bfb.name like #{pBrandName} or c.kondm like #{pBrandName} or TG.name like #{pBrandName})
</if>
bind 标签的两个属性都是必选项, name 为绑定到上下文的变量名, value 为 OGNL 表
达式。创建一个 bind 标签的变量后 , 就可以在下面直接使用,使用 bind 拼接字符串不仅可
以避免因更换数据库而修改 SQL,也能预防 SQL 注入。

相关文章:

  • 2021-09-30
  • 2022-12-23
  • 2021-08-22
  • 2022-01-12
  • 2021-09-27
  • 2022-12-23
  • 2021-12-10
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-12
  • 2021-07-13
  • 2021-12-18
  • 2022-12-23
  • 2021-04-06
相关资源
相似解决方案