Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9252357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:55:28+00:00 2026-06-18T10:55:28+00:00

I am creating a query below where a it retrieves data depending on the

  • 0

I am creating a query below where a it retrieves data depending on the term(s) the user entered in the a search bar. Now what I am trying to do is not display duplicate data, so if there are 2 rows where all the fields are exactly the same, then it is a duplicate row, so it only shows this row once not multiple times. Now I think it seems to do this as I see no duplicate rows but all I did was do a GROUP BY with all the SELECT fields except for the Answer field as it doesn’t let me have a group concat in the GROUP BY clause.

But what my question is that do I need that field in the GROUP Y clause to not show duplicate rows or is it not really needed?

SELECT
      q.QuestionContent, 
      o.OptionType, 
      q.NoofAnswers, 
      GROUP_CONCAT(DISTINCT Answer ORDER BY Answer SEPARATOR ',') AS Answer, 
      r.ReplyType, 
      q.QuestionMarks
    FROM Question q
    LEFT JOIN Answer an
      ON q.QuestionId = an.QuestionId
    LEFT JOIN Reply r 
      ON q.ReplyId = r.ReplyId 
    LEFT JOIN Option_Table o 
      ON q.OptionId = o.OptionId 
    WHERE ".implode(" AND ", array_fill(0, $numTerms, "q.QuestionContent LIKE ?"))."
    GROUP BY   q.QuestionContent, 
      o.OptionType, 
      q.NoofAnswers, 
      r.ReplyType, 
      q.QuestionMarks
    ORDER BY ".implode(", ", array_fill(0, $numTerms, "IF(q.QuestionContent LIKE ?, 1, 0) DESC"))."
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T10:55:30+00:00Added an answer on June 18, 2026 at 10:55 am

    No, you do not need the group_concat() in the select. The group by will ensure that any particular combination of values will appear once for the columns in the group by. Because these are guaranteed to be distinct, you don’t have to worry about any other columns.

    The group_concat() is a calculated column, based on the summaries. You are not permitted to have such columns in a group by statement. If you want to aggregate on them again, then you need to use a subquery.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a query, which will have various results depending on the parameters
I am creating a search, where the user can both choose an interval and
I am receiving the following error from the below query, as I am trying
I am creating a view with the query shown below: create view v2 as
I am creating a chunk of HTML/JavaScript with the below code: $result = mysql_query(SELECT
I am creating a query builder class that will help in constructing a query
i am dynamically creating sql query for inserting multiple records in one hit.Suppose no
I am creating a HUGE query with 5 or 6 join, and want to
I'm working on creating a SQL query that will pull records from a table
How to write a query for creating an stored procedure in mysql

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.