无效的方法:
select * from table1 where name like '%#name#%'
两种有效的方法:
1. 使用$代替#。此种方法就是去掉了类型检查,使用字符串连接,不过可能会有sql注入风险。
select * from table1 where name like '%$name$%'
2.使用连接符。不过不同的数据库中方式不同。
mysql:
select * from table1 where name like concat('%', #name#, '%')
oracle:
select * from table1 where name like '%' || #name# || '%'
sql server:
select * from table1 where name like '%' + #name# + '%'
注意:在实际开发中,往往我们需要将模糊查询的空格去掉。为了防止将去除空格放到业务层去,因此我建议如下写(oracle 中,其他数据库雷同):
select * from table1 where name like '%' || Trim(#name#) || '%'
相关推荐
iBATIS模糊查询
07_ibatis教程_模糊查询实体对象.zip 07_ibatis教程_模糊查询实体对象.zip
ibatis 相关使用文档及安装包ibatis 相关使用文档及安装包
ibatis中使用安全的拼接语句,动态查询,大于、小于、等于.doc
ibatis简易使用ibatis简易使用ibatis简易使用
07_ibatis教程_模糊查询实体对象.rar )
ibatis的实现(包含模糊查询、关联查询、增删改查) 数据库sql server 2005
NULL 博文链接:https://zmx.iteye.com/blog/515757
ibatis and和or联合查询 .doc
ibatis教程 主要是对这个软件的入门的介绍和如何加载和使用
ibatis动态多条件组合查询 实例 说明
Ibatis多表查询
Ibatis多表查询,一个小小的多表查询实例教你如何用ibatis进行多表查询
操作数据库 iBATIS查询,java 和spring的配置方法
Ibatis查询语句里,可以使用多表查询,返回多个表的值.doc
ibatis学习 ibatis总结 ibatis ibatis ibatis
ibatis 使用手册:ibatis 开发指南、ibatis sql maps、ibatis sql maps 入门教程。
Ibatis查询Id列表.doc
Ibatis复杂查询语句.doc