首页 > 数据库技术 > 详细

mybaitis动态sql利用bind标签代替%拼接完成模糊查询

时间:2018-08-31 12:59:55      阅读:237      评论:0      收藏:0      [点我收藏+]

  Oracle中使用bind的写法

<select id="selectUser" resultType="user" parameterType="user">
  <bind name="pattern" value="‘%‘ + username + ‘%‘" />
  select id,sex,age,username,password 
  from user
  where username LIKE #{pattern}
</select>

  Oracle中不使用bind的写法

  

<select id="selectUser" resultType="user" parameterType="user">
  select id,sex,age,username,password 
  from user
  where username LIKE  CONCAT(CONCAT(‘%‘,#{username}),‘%‘)
</select>

  

mybaitis动态sql利用bind标签代替%拼接完成模糊查询

原文:https://www.cnblogs.com/LingCoder/p/9565159.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!