php - Can the query below be corrected -


I need some help in that query where I do not know whether I SELECT clause, including section and selection by the right group In the right table from the field:

The database table below is:

Sessions table

  session ID session 1 name AAA 2 AAB   

Question table

  session question question question papers 1 1 2 2 What is it? What is 2 1 2 4 + 4? What is 3 2 1 10 + 10 and 11 + 11? What is 5 2 2 15 + 15? What is 5 2 3 20 + 20 and 40 + 40? 7   

Answer table

  Ansid Session Question Question 1 Answer 1 1B2 1 2C3 2A1A4 Below is query:  
  $ query = "Select q.SessionId, s   

is below 2 1D5 2 2A6 2DD2 2EE Session name, question question question, questionnaire Q & A, GROUP_ CONCAT (DISTINCT answer SEPARATOR '') AS answer, Q. Please include questions in the question Question s.SessionId = q.SessionId on Q Question Answer Question I = a .QuestionId where session name = "AAB" group I want to display every question relating to the "AAB" session, so it will ask the questions, exchanges, answers and question marks given below. Displaying:

  Question mark Q & A answer question question 1 10 + 10 and 11 + 11 What is AD5 2 15 + 15A5 What is 20 20 and 40 + 40?   

For the time being, if I ask questions in the search "AAB" session, then below it Radrshit being:

  QuestionId QuestionContent North Prsnmarts 1 10 + 10 and 11 + 11 What? What is AD5 2 15 + 15A5 is 20 20 and 40 + 40? What is de 7 1 10 + 10 and 11 + 11? What is AD5 2 15 + 15A5 is 20 20 and 40 + 40? What is de 7 1 10 + 10 and 11 + 11? What is AD5 2 15 + 15A5 is 20 20 and 40 + 40? What is de 7 1 10 + 10 and 11 + 11? What is AD5 2 15 + 15A5 is 20 20 and 40 + 40? What is de 7 1 10 + 10 and 11 + 11? What is AD5 2 15 + 15A5 is 20 20 and 40 + 40? DE 7    

Your answer table has a session ID that looks like you remember In addition to joining you, you should not need a difference in your group_concat, unless your storage of the same answer for the same question / session is not contingent, in that case, instead of coding the work around the query I solve that accident.

  SELECT q.SessionId, s.SessionName, q.QuestionId, q.QuestionContent, GROUP_CONCAT (DISTINCT answer SEPARATOR '') Answer, q. Answer the question from the session Marks INNER JOIN Question q s.SessionId = Q.SessionId Question Question Question. Question = A Question Question I and Session 

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -