I'm having a problem to perform a specific filter on a query in MySQL.
I'm building a search system where I have the following tables:
- Questionnaires : with the name of the questionnaires
-
Questions : containing the questions of the questionnaire, with
foreign key
pointing to the questionnaire table -
Answers : Containing the answers to each question, with
foreign key
pointing to questions - Bookmarks : Information about who responded
- Given Answers : Contains the answers given by each person.
I have the following structure:
[Tabela Fichas]
- ID
- created_at
- latitude
- longitude
[Tabela Respostas dadas]
- id
- ficha_id
- resposta_id
- pergunta_id
I need a query that returns me the amount of respostas_id
according to a specific question.
For example, I need to know who answered "23" in the resposta_id
field when pergunta_id = "81"
answered the other questions.
I've been pounding for days on this but I can not. I even thought about creating a view that organized the data so that each question was a column and the answers were the lines, but I could not.