Mybatis模糊搜尋引數有英文單引號解決方案

2021-10-05 14:41:12 字數 653 閱讀 8620

當模糊查詢自動觸發時,使用者如果使用打字法輸入漢字還沒輸入完,預設傳送到後台的引數是以拼音加單引號的形式,這時mybatis模糊查詢會報錯。

環境:mybatis、oracle

原語句:

select

id,shopid,

productinfoid,

uploadlocation,

imagename,

shopname,

productname,

type

from

photo_info

and shopname like '%$%'

order by id

修改後的語句:

select

id,shopid,

productinfoid,

uploadlocation,

imagename,

shopname,

productname,

type

from

photo_info

and shopname like concat(concat('%',#),'%')

order by id

Mybatis 模糊查詢

mybatis從入門到精通 書籍筆記 1 使用concat 字串連線函式and user name like concat and user name like concat concat mysql中concat函式可以連線多個引數,oracle中只支援2個引數,所以有些要用多個concat 函式...

mybatis模糊查詢實現

最近在用mybatis做模糊查詢的時候,這個 xx 不知道怎麼插入,直接寫在sql語句裡面沒法實現,在網上查了一下主要有兩種比較好的方式實現 1.使用標籤 select from table where field like 注意 paramter代指傳入的引數,如果引數型別是基本資料型別或者它們對...

mybatis 配置 模糊查詢

使用mybatis連線mysql的話,需要如下步驟 1 生成實體類。public class user implements serializable2 生成主配置檔案,放在resources下面 主配置檔案也可以這樣寫,將連線資料庫的 放到外面 jdbcconfig.properties裡的內容 ...