From 1a3ecaf9e073c2b6398241258ff0b1e5921ce464 Mon Sep 17 00:00:00 2001 From: czm Date: Wed, 6 Jan 2021 00:39:18 +0800 Subject: [PATCH] question random update --- .../main/resources/mapper/QuestionMapper.xml | 66 ++++++++++++++----- xzs-new.sql | 44 ++++++++++++- 2 files changed, 92 insertions(+), 18 deletions(-) diff --git a/source/xzs/src/main/resources/mapper/QuestionMapper.xml b/source/xzs/src/main/resources/mapper/QuestionMapper.xml index 2cc1a6c..7231506 100644 --- a/source/xzs/src/main/resources/mapper/QuestionMapper.xml +++ b/source/xzs/src/main/resources/mapper/QuestionMapper.xml @@ -234,23 +234,55 @@ diff --git a/xzs-new.sql b/xzs-new.sql index f47fdd6..2384026 100644 --- a/xzs-new.sql +++ b/xzs-new.sql @@ -373,4 +373,46 @@ CREATE TABLE `t_user_token` ( SET FOREIGN_KEY_CHECKS = 1; -(SELECT * FROM t_question WHERE skill_id = 1 LIMIT 2) UNION (SELECT * FROM t_question WHERE skill_id = 11 LIMIT 2) ; \ No newline at end of file +(SELECT * FROM t_question WHERE skill_id = 1 LIMIT 2) UNION (SELECT * FROM t_question WHERE skill_id = 11 LIMIT 2) ; + + +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 + FROM + t_question AS r1 + JOIN ( + SELECT + ( + RAND() * ( + SELECT + MAX(id)-7 + 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 + WHERE + r1.deleted=0 AND + r1.id >= r2.row_id + AND r1.skill_id = 10 + ORDER BY + r1.id ASC + LIMIT 7 + ) 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; \ No newline at end of file