oracle 在 MyBatis 中使用 like

两种使用方法sql

使用oracle自带 || 拼凑的方式

<if test="userName!=null and userName!=''">
   AND u.USER_NAME like '%' || #{userName} || '%'
</if>
oracle

使用MyBatis的$符号的方式

<if test="userName!=null and userName!=''">
   AND u.USER_NAME like '%${userName}%'
</if>
spa

总结:实测两种方式都可。推荐orcale自带 || 拼凑符号方式。由于MyBatis的$符号有sql注入风险

相关文章
相关标签/搜索