UPDATE:
Below is my query:
$questionquery = "
SELECT q.QuestionId, q.QuestionContent, o.OptionType, q.NoofAnswers, GROUP_CONCAT(an.Answer ORDER BY an.Answer SEPARATOR ' ') AS Answer, r.ReplyType,
q.QuestionMarks
FROM Answer an
INNER JOIN Question q ON q.AnswerId = an.AnswerId
JOIN Reply r ON q.ReplyId = r.ReplyId
JOIN Option_Table o ON q.OptionId = o.OptionId
WHERE ".implode(" AND ", array_fill(0, $numTerms, "q.QuestionContent LIKE ?"))."
GROUP BY q.QuestionId, q.SessionId, q.QuestionContent, o.OptionType, q.NoofAnswers, Answer, r.ReplyType, q.QuestionMarks
ORDER BY ".implode(", ", array_fill(0, $numTerms, "IF(q.QuestionContent LIKE ?, 1, 0) DESC"))."
";
The above query will provide a search on a string and output the rows which contains that string under the “Question” column.
I have a URL you can access on my application, please follow the steps below in order to use the application:
- Step 1: When you open application, you see a green plus button on the
page, click on it and it will display a modal window. - Step 2: In modal window there is a search bar, type in “AAA” and
submit search, you will see a bunch of rows appear.
Now as you can see if you read carefully there are some rows which re exact duplicates, as in having the exact same content within each column (same question, answer, marks, number of replies etc all the same)
This is what I want to get rid of. I don;t want it to show duplicate rows but to simply just show one of those rows so it doesn’t output duplicate row. What do I need to change?
To not show duplicate rows, unless I’m missing something, you just need to add the DISTINCT clause, like this: