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注入風險

相關文章
相關標籤/搜索