USE study; -- 1. 查看所有没有正确答案的题目 SELECT id, question_type, LEFT(question_content, 40) AS content, correct_answer, CASE WHEN correct_answer IS NULL OR correct_answer = '' THEN 'EMPTY' ELSE 'OK' END AS status FROM question WHERE correct_answer IS NULL OR correct_answer = '' ORDER BY id; -- 2. 查看题库中没有正确答案的题目 SELECT id, bank_id, question_type, LEFT(question_content, 40) AS content, correct_answer, CASE WHEN correct_answer IS NULL OR correct_answer = '' THEN 'EMPTY' ELSE 'OK' END AS status FROM question_bank_item WHERE correct_answer IS NULL OR correct_answer = '' ORDER BY id; -- 3. 统计有问题的题目数量 SELECT '考试题目' AS source, question_type, COUNT(*) AS count FROM question WHERE correct_answer IS NULL OR correct_answer = '' GROUP BY question_type UNION ALL SELECT '题库题目' AS source, question_type, COUNT(*) AS count FROM question_bank_item WHERE correct_answer IS NULL OR correct_answer = '' GROUP BY question_type; -- 4. 对于多选题,如果答案为空,可以设置一个默认值(需要手动确认) -- 警告:这会修改数据,请先备份! -- UPDATE question -- SET correct_answer = 'A' -- WHERE question_type = 'multiple' -- AND (correct_answer IS NULL OR correct_answer = '') -- AND id IN (具体的ID); -- 5. 查看特定考试的题目答案情况 SELECT q.id, e.exam_name, q.question_type, LEFT(q.question_content, 30) AS content, q.correct_answer FROM question q LEFT JOIN exam e ON q.exam_id = e.id WHERE e.exam_name LIKE '%Test%' ORDER BY q.exam_id, q.id;