mybatis like模糊查询问题

╰半夏微凉° 2022-05-30 00:35 417阅读 0赞
  1. 参数中直接加入%%

  param.setUsername(“%CD%”);
param.setPassword(“%11%”);

  1. <select id="selectPersons" resultType="person" parameterType="person">
  2. select id,sex,age,username,password from person where true
  3. <if test="username!=null"> AND username LIKE #{username}</if>
  4. <if test="password!=null">AND password LIKE #{password}</if>
  5. </select>
  1. bind标签

  1. CONCAT

    where username LIKE concat(concat(‘%’,#{username}),’%’)

发表评论

表情:
评论列表 (有 0 条评论,417人围观)

还没有评论,来说两句吧...

相关阅读