方案一
<select id="selectPersons" resultType="person" parameterType="person">
<bind name="pattern" value="'%' + _parameter.username + '%'" />
select id,sex,age,username,password
from person
where username LIKE #{pattern}
</select
方案二
使用 ${...} 代替 #{...}
SELECT * FROM tableName WHERE name LIKE '%${text}%';
方案三
java 代码
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}\"%\"");
}
网友评论