在使用MyBatis框架的时候,难免会遇到些sql语句的,那么在对应Dao层的映射文件中模糊查询也是写得比较多的,那么在使用like的时候,mapper文件怎么写呢?
解决方法:使用concat
,其功能相当于字符串连接符 ||,concat(字串1, 字串2, 字串3, …),将字串1、字串2、字串3,等字串连在一起。
<if test="params.name!= null and params.name!= ''">
and v.`name` like concat('%',#{params.name},'%')
</if>
这样就能够实现模糊查询了。。。