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
posted @ 2018-11-09 16:06  fleam  阅读(114)  评论(0编辑  收藏  举报