`

ibatis中使用like模糊查询

 
阅读更多

平常我们使用查询可以如下:

<select id="findObjectByCode" parameterClass="java.lang.String" resultClass="Object">

select * from tab where code = #code#

</select> 

如果想模糊查询,那么就不可以直接code like %#code#%了,需要改为code like '%$code$%'或者code like  '%'+#code#+'%'就可以得到你想要的结果了,不然就要报错了. 还有平时在用IN时,也需要用$这个符号,可以自动用逗号分隔几个参数。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics