<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="dnn.exam.QuestionMapper">
<select id="getQuestionList" resultType="dnn.exam.Question">
SELECT * FROM (SELECT * FROM question
<where> 1 = 1
<if test="null != questionids and questionids.size() > 0">
AND
<foreach collection="questionids" index="index" item="item" open="(" separator="and" close=")">
id != #{item}
</foreach>
</if>
</where>
ORDER BY question.count ASC LIMIT 5) tab ORDER BY RAND()
</select>
</mapper>
Mybatis的Mapper.xml文件中集合遍历
最新推荐文章于 2024-04-07 10:12:51 发布
本文深入探讨了MyBatis框架下复杂SQL查询的编写技巧,重点讲解了如何使用动态SQL实现灵活的条件过滤和结果排序,通过具体案例解析了<if>标签和<foreach>集合迭代在实际应用中的作用。
7123

被折叠的 条评论
为什么被折叠?



