Mybatis几种模糊查询方式
方式一:
<select id="selectList" parameterType="String" resultType="hashMap">
select * from bloginfo where blog_title like concat('%',#{blogTitle},'%')
</select>
方式二:
<select id="selectList" parameterType="String" resultType="hashMap">
select * from bloginfo where blog_title like "%"#{blogTitle}"%"
</select>
方式三:
<select id="selectList" parameterType="String" resultType="hashMap">
<bind name="blogTitle" value="'%'+_parameter+'%'"/>
select * from bloginfo where blog_title like #{blogTitle}
</select>
方式四:
在java代码对传入的参数进行改造
if (!"".equals(blogTitle) && blogTitle != null) {
blogTitle = "%"+blogTitle+"%";
}
注:LZ使用的Mysql进行的实验。