Mybatis中Mapper.xml遍历集合

代码案例

<select id="selectProductByCategoryId" resultMap="BaseResultMap">
  select id, category_id, product_name, subtitle, main_image, price, stock, product_status,
  create_time, update_time, sub_images, detail
  from mall_product where product_status = 1
  <if test="categoryIds.size() > 0">
      and category_id in
      <foreach collection="categoryIds" item="item" index="index" open="(" separator="," close=")">
        ${item}
      </foreach>
  </if>
</select>

你可能感兴趣的:(mybatis,mybatis,java)