Mybatis模糊查询

       Mybatis模糊查询

<mapper namespace="test">
        <!-- 第一种模糊查询 '%'空格#{数据}空格'%'-->
    <select id="selectStudentAll"    resultType="stu">
            select *from student where name like '%' #{name} '%'
    </select>
        <!-- 第二种:使用数据库字符串拼接函数concat拼接数据 -->
    <select id="selectStudentAll2"    resultType="stu">
            select *from student where name like concat('%',#{name},'%')
    </select>
        <!-- 第三种:${}直接使用字符串拼接,内容必须是value,没有使用预编译执行语句,这样安全低 -->
    <select id="selectStudentAll3"    resultType="stu">
            select *from student where name like '%${value}%'
    </select>
</mapper>

 

posted @ 2018-06-19 15:57  J-Joyce  阅读(136)  评论(0编辑  收藏  举报