zoukankan      html  css  js  c++  java
  • Mybatis实现in查询(注解形式和xml形式)

    1. @Select注解中使用in

        @Select({"<script> " +
                " select * "+
                " from business_threat bt 
    " +
                " join abnormal_event_type aet on bt.event_type_id = aet.id " +
                " where 1=1 " +
                " <if test = " ids != null "> " +
                " and bt.id in " +
                " <foreach item = 'item' index = 'index' collection = 'ids' open = '(' separator = ',' close = ')' > " +
                " #{item} " +
                " </foreach> " +
                " </if> " +
                "</script>"})
        List<BusinessThreatVO> getByBusinessThreadId(@Param("ids") List<Long> ids);

    2. xml中使用in

      <select id="findByModelInMarket" resultMap="BaseResultMap">
      select
      <include refid="Base_Column_List" />
      from device
      WHERE replace(lower(model_in_market), ' ', '') = replace(lower(#{modelInMarket}), ' ', '')
      AND status IN <foreach collection="deviceStatus" item="status" open="(" close=")" separator=",">#{status}</foreach>
      </select>
  • 相关阅读:
    H
    饭卡(0 1背包)
    J
    H
    E
    3991: [SDOI2015]寻宝游戏
    CF 1051 F. The Shortest Statement
    CF 643 E. Bear and Destroying Subtrees
    4567: [Scoi2016]背单词
    4946: [Noi2017]蔬菜
  • 原文地址:https://www.cnblogs.com/miaoying/p/8276089.html
Copyright © 2011-2022 走看看