I am puzzling over how to do this in SQL. I have a table:
| User_id | Question_ID | Answer_ID | | 1 | 1 | 1 | | 1 | 2 | 10 | | 2 | 1 | 2 | | 2 | 2 | 11 | | 3 | 1 | 1 | | 3 | 2 | 10 | | 4 | 1 | 1 | | 4 | 2 | 10 |
It contains user responses to a specific question. A question may have several answers. The user cannot answer the same question twice. (Therefore, there is only one answer identifier for {User_id, Question_ID})
I am trying to find the answer to this query: for a specific question and id (related to the same question), I want to find the most general answer posed by the Other question to users with this answer.
For example, for the above table:
For question_id = 1 -> For Answer_ID = 1 - (Question 2 - Answer ID 10) For Answer_ID = 2 - (Question 2 - Answer ID 11)
Is it possible to do in one request? Should this be done in a single request? Should I just use a stored procedure or Java to do this?
mysql
Stationarytraveller
source share