MyBatis like 语句查询

2022-10-31 14:05:36 浏览数 (2)

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>

0 人点赞