2
I’m performing the following consultation:
SELECT enquete.image,
enquete.status AS status_enquete,
enquete.id AS id_enquete,
enquete.title AS titulo_enquete,
perguntas.id AS id_pergunta,
perguntas.title AS titulo_pergunta
FROM obs_survey_questions AS perguntas
INNER JOIN obs_survey AS enquete
ON enquete.id = perguntas.survey_id
INNER JOIN (SELECT id
FROM obs_survey
GROUP BY id) b
ON perguntas.survey_id = b.id
WHERE status = 1
GROUP BY id_pergunta
And getting the following result:
However, my goal is that it comes only from ONE ID_ENQUETE, but I don’t know why there’s always two, in the case above, the 14 and the 1.
indicates which ID (id_poll) of the poll you want to return only and then make use of a GROUP BY id_poll.
– ElvisP
But which ID should be returned? Just return one? What is the purpose of the query? You have to go into more detail about your question, otherwise it’s hard to help.
– João Martins
@Joãomartins The problem is that all surveys with status 1 are coming, but I only want the first active and their respective questions.
– Lollipop