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

  • Home
  • SEARCH
  • 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 9095773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:41:22+00:00 2026-06-16T23:41:22+00:00

SELECT DISTINCT q.QuestionContent, o.OptionType, q.NoofAnswers, GROUP_CONCAT(DISTINCT Answer ORDER BY Answer SEPARATOR ”) AS Answer,

  • 0
SELECT DISTINCT q.QuestionContent, o.OptionType, q.NoofAnswers, GROUP_CONCAT(DISTINCT Answer ORDER BY Answer SEPARATOR '') AS Answer, r.ReplyType, 
q.QuestionMarks
FROM Answer an 
INNER JOIN Question q ON q.QuestionId = an.QuestionId
JOIN Reply r ON q.ReplyId = r.ReplyId 
JOIN Option_Table o ON q.OptionId = o.OptionId 

My query above is displaying an empty set of results even though it should display some results. It is suppose to display each distinct question (What I mean by this is that it should distinctly display rows so that there are no duplicate rows that contains exactly the same data across all columns) Can anyone fix the query so it outputs the results it should output? Below are the tables:

Session Table:

SessionId  SessonName
3          ANDES

Question Table:

QuestionId  SessionId   QuestionNo  QuestionContent       NoofAnswers   ReplyId     QuestionMarks   OptionId
1           3           1           What is 2+2?          1                 1           5               2
2           3           2           What is 2+2?          1                 1           5               2
3           3           3           Name these 2 flowers  2                 2           5               4

Answer Table:

AnswerId (Auto)  QuestionId  Answer
1                1           A
2                1           B
3                2           A
4                2           D
5                3           C

Reply Table:

ReplyId  ReplyType
1        Single
2        Multiple

Option Table:

OptionId OptionType
1        A-C
2        A-D
3        A-E
4        A-F
  • 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-16T23:41:23+00:00Added an answer on June 16, 2026 at 11:41 pm

    I altered your query slightly and I am getting results. First, I changed to use a LEFT JOIN, then you will get questions returned if there is no answer, etc in the additional tables. Second, since you are using a aggregate function GROUP_CONCAT(), you need to use a GROUP BY:

    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 
    group by q.QuestionContent
    

    See SQL Fiddle with Demo

    This returns the result:

    |      QUESTIONCONTENT | OPTIONTYPE | NOOFANSWERS | ANSWER | REPLYTYPE | QUESTIONMARKS |
    ----------------------------------------------------------------------------------------
    | Name these 2 flowers |        A-F |           2 |      C |  Multiple |             5 |
    |         What is 2+2? |        A-D |           1 |    ABD |    Single |             5 |
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this query below: SELECT q.SessionId, s.SessionName, q.QuestionId, q.QuestionContent, GROUP_CONCAT(DISTINCT Answer ORDER BY
I have this query: SELECT DISTINCT IM.EDIFICIOS_ID, TI.TITULAR FROM IMPORTACION IM INNER JOIN I_EDIFICIO
SELECT DISTINCT a.userID, buildstatus FROM meeting a WHERE buildStatus = 'complete' INNER JOIN user.contactName
Select DISTINCT wpg.ID as id1,wr.ID as id2 FROM Table1 wpg inner join Table2 wp
Select distinct A.col1, B.col2, col3 from A inner join B on A.id = B.id
SELECT DISTINCT tr.object_id,tt.taxonomy, im . * FROM term_relationships AS tr INNER JOIN term_taxonomy AS
This works SELECT DISTINCT b.b_id FROM b INNER JOIN c ON b.b_id=c.b_id WHERE c.active='yes'
My query is: SELECT DISTINCT IncidentStatus.IncidentStatusName, Incident.IncidentID AS Bob FROM Incident INNER JOIN IncidentMember
Query: SELECT DISTINCT ([Equipment List].ID) AS Expr1, [Job Assignments].Job FROM [Equipment List] LEFT JOIN
The following query: SELECT DISTINCT ClassName FROM SiteTree ORDER BY ClassName is returning things

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.