Mybatis 的like模糊查詢

select * from person where name  like "%"#{name}"%" spa

select * from person where name  like '%'||#{name}||'%' code

select * from person where name  like '%${name}%' 編譯

where username LIKE concat(cancat('%',#{username}),'%')

三種寫法對比後,第一種屬於預編譯SQL,後兩種都不是,所以推薦使用第一種寫法 select

相關文章
相關標籤/搜索