question random update
This commit is contained in:
		
							parent
							
								
									1a3ecaf9e0
								
							
						
					
					
						commit
						487e184a9c
					
				@ -234,38 +234,34 @@
 | 
			
		||||
  <select id="selectQuestionsByQuestionsNumber"
 | 
			
		||||
          resultMap="BaseResultMap">
 | 
			
		||||
    <foreach collection="eachList" item="each" separator="union">
 | 
			
		||||
      (SELECT
 | 
			
		||||
        q.skill_id,
 | 
			
		||||
        q.industry_id,
 | 
			
		||||
        i. NAME AS industry_name,
 | 
			
		||||
        s. NAME AS skill_name,
 | 
			
		||||
        t.content,
 | 
			
		||||
        q.difficult,
 | 
			
		||||
        q.question_type
 | 
			
		||||
      FROM
 | 
			
		||||
        t_question q
 | 
			
		||||
      JOIN (
 | 
			
		||||
      (
 | 
			
		||||
        SELECT
 | 
			
		||||
          r1.id
 | 
			
		||||
            q.skill_id,
 | 
			
		||||
            q.industry_id,
 | 
			
		||||
            i. NAME AS industry_name,
 | 
			
		||||
            s. NAME AS skill_name,
 | 
			
		||||
            t.content,
 | 
			
		||||
            q.difficult,
 | 
			
		||||
            q.question_type
 | 
			
		||||
        FROM
 | 
			
		||||
          t_question AS r1
 | 
			
		||||
          t_question AS q
 | 
			
		||||
        JOIN (
 | 
			
		||||
        SELECT
 | 
			
		||||
          (
 | 
			
		||||
            RAND() * (
 | 
			
		||||
            SELECT
 | 
			
		||||
              MAX(id)-#{each.eachNumber}
 | 
			
		||||
              MAX(id)
 | 
			
		||||
            FROM
 | 
			
		||||
              t_question
 | 
			
		||||
            )
 | 
			
		||||
          ) AS row_id
 | 
			
		||||
        ) AS r2
 | 
			
		||||
        JOIN t_industry i ON i.id = r1.industry_id
 | 
			
		||||
        JOIN t_skill s ON s.id = r1.skill_id
 | 
			
		||||
        JOIN t_text_content t ON t.id = r1.info_text_content_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
 | 
			
		||||
        <where>
 | 
			
		||||
          r1.deleted=0 AND
 | 
			
		||||
          r1.id >= r2.row_id
 | 
			
		||||
          q.deleted=0 AND
 | 
			
		||||
          q.id >= r2.row_id
 | 
			
		||||
          <if test="each.difficult != null">
 | 
			
		||||
            and q.difficult = #{each.difficult}
 | 
			
		||||
          </if>
 | 
			
		||||
@ -277,12 +273,9 @@
 | 
			
		||||
          </if>
 | 
			
		||||
        </where>
 | 
			
		||||
        ORDER BY
 | 
			
		||||
        r1.id ASC
 | 
			
		||||
        q.id ASC
 | 
			
		||||
        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>
 | 
			
		||||
 | 
			
		||||
  </select>
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user