<!-- sql片段 id 表示唯一标示 这里不加where是因为 sql片段只对单表查询才抽取出来  这样的重用性更高 -->
    <sql id="query_user_where">
        <if test="userCustom!=null">
            <if test="userCustom.username != null and userCustom.username !=''">
                 user.username like('%${userCustom.username}%')
             </if>
        </if>
        <!-- and(id=3 or id=6 or id=7) -->
        <!-- collection包装对象的属性 item 集合属性的单个对象  open 拼接开始字符串 close 拼接结束字符串 separator 每次遍历中间的分割字符串-->
        <foreach collection="ids" item="id" open="and(" close=")" separator="or">
            id=#{id}
        </foreach>
    </sql>

 

相关文章:

  • 2021-05-20
  • 2022-01-04
  • 2022-01-09
  • 2021-07-26
  • 2021-09-02
猜你喜欢
  • 2021-07-15
  • 2022-12-23
  • 2021-11-20
  • 2021-12-17
  • 2022-12-23
  • 2021-06-14
  • 2021-12-06
相关资源
相似解决方案