MyBatis like 语句查询
like CONCAT(’%’,#{keyWord},’%’)
用CONCAT() 是最为推荐的。
代码语言:javascript复制 <select id="queryNewsByKeyWord" resultMap="newsAll">
SELECT * from news LEFT join sort on news.type=sort.sort_id
where key_word like CONCAT('%',#{keyWord},'%')
or
author like CONCAT('%',#{keyWord},'%')
or
title like CONCAT('%',#{keyWord},'%')
</select>