0

I am working on a quiz module where I want to show the user the wrong answered questions from his quiz result. The result of quiz is stored in one table t1_result with columns user_id, question_id, option_id and the correct answers for quiz questions are stored in another table t2_answers with question_id and correct_answer_id. Now I want to match the two result sets and find unmatched question and answer combinations. I have looked around and tried few queries but no luck till now. Looking for some insights over this.

t1_result
+----+------+---------------------+
| user_id | question_id| option_id|
+----------+------------+----------+
| 11       | 41        | 213      |
+----------+-----------+----------+
| 11       | 42        | 222      |
+----------+-----------+----------+
| 11       | 43        | 295      |
+----------+-----------+----------+
| 11       | 44        | 265      |
+----------+-----------+----------+
| 11       | 45        | 145      |
+----------+-----------+----------+

t2_answers 
+----+------+---------------------+
| question_id  | correct_answer_id|
+----+---------+------------------+
| 41         | 11                 |
+----+---------+------------------+
| 42         | 14                 |
+----+---------+------------------+
| 43         | 15                 |
+----+---------+------------------+ 
| 44         | 265                |
+----+---------+------------------+ 
| 45         | 145                |
+----+---------+------------------+ 
Ansh
  • 269
  • 2
  • 15
  • It would help quite a bit if you added the full table structure for both tables, including any other columns and any relations between them. – Andrei Dec 20 '18 at 06:33
  • I tried inserting the table details and structure but could not due to displaced alignment. Can you guide me how can i send the table details – Ansh Dec 20 '18 at 06:35
  • You can do this in one query by joining the two tables and filtering the resultset as described in the duplicate topic. – Shadow Dec 20 '18 at 06:39
  • @Andrei I have made edits. Please take a look if you find some time. – Ansh Dec 20 '18 at 06:55
  • Thanks@Shadow for this. But can you help me in building the query. I am trying but not getting the results. It will be a real help – Ansh Dec 20 '18 at 07:09

0 Answers0