ibatis中使用like模糊查询
来源:互联网 发布:淘宝海报图片 编辑:程序博客网 时间:2024/04/27 17:46
1.问题
select * from t_comment where content LIKE '%#keyword#%'
提示:Parameter index out of range (x > number of parameters, which is y.),x、y为数字
2.解决
参考http://www.cnblogs.com/gaojing/archive/2013/01/04/2844932.html
2.1 使用$代替#。此种方法就是去掉了类型检查,使用字符串连接,不过可能会有sql注入风险。
select * from t_comment where content LIKE '%$keyword$%'
2.2 使用连接符。不过不同的数据库中方式不同。
mysql:
<span style="font-size:14px;">select * from t_comment where content like concat('%', #keyword#, '%')</span>oracle:
<span style="font-size:14px;">select * from t_comment where content like '%' || #keyword# || '%'</span>sql server:
<span style="font-size:14px;">select * from t_comment where content like '%' + #keyword# + '%'</span>
0 0
- ibatis中使用like模糊查询
- ibatis中使用like模糊查询
- ibatis中使用like模糊查询
- ibatis中使用like模糊查询
- ibatis中使用like模糊查询
- ibatis中使用like模糊查询
- ibatis中使用like模糊查询
- ibatis中使用like模糊查询
- 【转】ibatis中使用like模糊查询
- ibatis中使用like模糊查询
- ibatis中使用like模糊查询
- ibatis中使用like模糊查询
- ibatis模糊查询(like)
- iBatis like模糊查询
- iBatis 中 Like '%iBatis%' 的写法实现模糊查询
- iBatis 中 Like '%iBatis%' 的写法实现模糊查询
- iBatis 中 Like '%iBatis%' 的写法实现模糊查询
- ibatis 的 like模糊查询
- Server2012R2下安装intel 82579v网卡驱动
- c++项目练习
- 数组 3Sum
- android的消息处理机制(图+源码分析)——Looper,Handler,Message
- android获取手机内部存储空间和外部存储空间
- ibatis中使用like模糊查询
- UNITY3D 使用 litjson 制作数据表
- Reduce对Pig作业性能的影响
- android动画坐标定义
- Android 自定义的圆形变化ProgressBar
- [转]一个手机游戏的服务器架构
- 学习C指针的心得随笔
- Leetcode:Palindrome Partitioning
- error和exception的区别,RuntimeException和非RuntimeException的区别