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

  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>

  

posted @ 2018-08-31 12:21  牛哥聊技术  阅读(796)  评论(0编辑  收藏  举报