select * from person where name like "%"#{name}"%"<!--推薦使用-->java
select * from person where name like '%'||#{name}||'%'ide
select * from person where name like '%${name}%'code
public class ArticleSQLProvider { private final static String TABLE_NAME = "tab_article"; public String findByArticle(final Article article){ return new SQL(){ { SELECT("*"); FROM(TABLE_NAME); if(article.getArticleId()!=null){ WHERE("articleId = #{articleId}"); } if (article.getTitle()!=null){ WHERE("title like \"%\"#{title}\"%\""); } if(article.getContent()!=null){ WHERE("content like \"%\"#{content}\"%\""); } } }.toString(); } }