MyBatis foreach

foreach

Another common necessity for dynamic SQL is the need to iterate over a collection, often to build an IN condition. For example:

<select id="selectPostIn" resultType="domain.blog.Post">
  SELECT *
  FROM POST P
  WHERE ID in
  <foreach item="item" index="index" collection="list"
      open="(" separator="," close=")">
        #{item}
  </foreach>
</select>


http://www.mybatis.org/mybatis-3/dynamic-sql.html
原文地址:https://www.cnblogs.com/hellowzd/p/9935659.html