Mybatis中的like查询
源:http://blog.csdn.net/zhang98722/article/details/6956571
评:
今天要做一个模糊查询
用的Mybatis
开始写的是:
[html]viewplaincopy
selectid,bookName,author,publisher,donor,status,createDate,lastUpdatefrombook
<where>
<iftest="bookName!=null">
bookNamelike'%#{bookName}%'
</if>
<iftest="author!=null">
andauthorlike'%#{author}%'
</if>
最后改为:
[html]viewplaincopy
selectid,bookName,author,publisher,donor,status,createDate,lastUpdatefrombook
<where>
<iftest="bookName!=null">
bookNamelikeCONCAT('%','${bookName}','%')
</if>
<iftest="author!=null">
andauthorlikeCONCAT('%','${author}','%')
</if>
主要还是MyBatis传值的问题啊
如果不是字符串就没法替换了
相关推荐
xiuyangsong 2020-11-16
Nishinoshou 2020-11-09
jimgreatly 2020-09-01
dongxurr 2020-08-18
Dullonjiang 2020-08-15
Dullonjiang 2020-08-11
Dullonjiang 2020-08-09
dongxurr 2020-08-08
yunzhonmghe 2020-08-07
jimgreatly 2020-08-03
Dullonjiang 2020-07-30
jimgreatly 2020-07-27
liqiancao 2020-07-26
xiuyangsong 2020-07-26
dongxurr 2020-07-26
mcvsyy 2020-07-26
helloxusir 2020-07-25
牧场SZShepherd 2020-07-20