一般情况
@select(“select * from user where name = #{name}”)
List selectUserByName (String name)
高级用法
@Select(“select * from userf where name like CONCAT(’%’,#{s},’%’)”)
List selectLikename(String s);
concat拼接字符串
CONCAT(’%’,#{0},’%’)") 不能直接用 ‘%#{s}%’
本文介绍了使用MyBatis进行数据库查询的高级技巧,包括通过动态SQL实现模糊查询及字符串拼接等操作。
一般情况
@select(“select * from user where name = #{name}”)
List selectUserByName (String name)
高级用法
@Select(“select * from userf where name like CONCAT(’%’,#{s},’%’)”)
List selectLikename(String s);
concat拼接字符串
CONCAT(’%’,#{0},’%’)") 不能直接用 ‘%#{s}%’
4350

被折叠的 条评论
为什么被折叠?