码迷,mamicode.com
首页 > 其他好文 > 详细

MyBatis中的模糊查询

时间:2019-10-20 19:53:40      阅读:109      评论:0      收藏:0      [点我收藏+]

标签:ring   parameter   soft   col   where   style   username   ike   res   

根据用户名模糊查询客户信息

方法一:

<select id="findUserByName" parameterType="java.lang.String" resultType="User">
  select * from t_customer where username like ‘%${value}%‘
</select>


方法二:

<select id="findUserByName" parameterType="java.lang.String" resultType="User">
  select * from t_customer where username like concat(‘%‘,‘${value}‘,‘%‘)
</select>

 

关键点:由于parameterType为String类型   所以在SQL语句中都使用${}表示拼接类型,否则会引起报错。

 

MyBatis中的模糊查询

标签:ring   parameter   soft   col   where   style   username   ike   res   

原文地址:https://www.cnblogs.com/Rando_M/p/11708661.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!