question random update

This commit is contained in:
czm 2021-01-06 22:05:51 +08:00
parent 1a3ecaf9e0
commit 487e184a9c

View File

@ -234,7 +234,8 @@
<select id="selectQuestionsByQuestionsNumber" <select id="selectQuestionsByQuestionsNumber"
resultMap="BaseResultMap"> resultMap="BaseResultMap">
<foreach collection="eachList" item="each" separator="union"> <foreach collection="eachList" item="each" separator="union">
(SELECT (
SELECT
q.skill_id, q.skill_id,
q.industry_id, q.industry_id,
i. NAME AS industry_name, i. NAME AS industry_name,
@ -243,29 +244,24 @@
q.difficult, q.difficult,
q.question_type q.question_type
FROM FROM
t_question q t_question AS q
JOIN (
SELECT
r1.id
FROM
t_question AS r1
JOIN ( JOIN (
SELECT SELECT
( (
RAND() * ( RAND() * (
SELECT SELECT
MAX(id)-#{each.eachNumber} MAX(id)
FROM FROM
t_question t_question
) )
) AS row_id ) AS row_id
) AS r2 ) AS r2
JOIN t_industry i ON i.id = r1.industry_id JOIN t_industry i ON i.id = q.industry_id
JOIN t_skill s ON s.id = r1.skill_id JOIN t_skill s ON s.id = q.skill_id
JOIN t_text_content t ON t.id = r1.info_text_content_id JOIN t_text_content t ON t.id = q.info_text_content_id
<where> <where>
r1.deleted=0 AND q.deleted=0 AND
r1.id >= r2.row_id q.id >= r2.row_id
<if test="each.difficult != null"> <if test="each.difficult != null">
and q.difficult = #{each.difficult} and q.difficult = #{each.difficult}
</if> </if>
@ -277,12 +273,9 @@
</if> </if>
</where> </where>
ORDER BY ORDER BY
r1.id ASC q.id ASC
LIMIT #{each.eachNumber} LIMIT #{each.eachNumber}
) AS rows ON (rows.id = q.id) )
JOIN t_industry i ON i.id = q.industry_id
JOIN t_skill s ON s.id = q.skill_id
JOIN t_text_content t ON t.id = q.info_text_content_id)
</foreach> </foreach>
</select> </select>