So I have five tables I am trying to get back in one query
parent_section(id, gate_id)
Assessment_Question(id,parent_section_id)
Assessment_question_multi_choice_option(id, question_id)
Assessment_answer_Group(id, entity_id)
Assessment_Answer(id,assessment_question_id, assessment_answer_Group_id)
I am trying to list all questions
Error is Unknown column 'ideas_service.parent_section.id' in 'on clause'
Here is my query
dsl.select()
.from(PARENT_SECTION,ASSESSMENT_ANSWER_GROUP)
.join(ASSESSMENT_QUESTION)
.on(PARENT_SECTION.ID.eq(ASSESSMENT_QUESTION.PARENT_SECTION_ID))
.leftJoin(ASSESSMENT_QUESTION_MULTI_CHOICE_OPTION)
.on(
ASSESSMENT_QUESTION_MULTI_CHOICE_OPTION.ASSESSMENT_QUESTION_ID.eq(
ASSESSMENT_QUESTION.ID))
.join(ASSESSMENT_ANSWER)
.on(ASSESSMENT_ANSWER_GROUP.ID.eq(ASSESSMENT_ANSWER.ASSESSMENT_ANSWER_GROUP_ID))
.where(PARENT_SECTION.GATE_ID.eq(gateId))
.fetch()
Previously when I was only trying to query the table for three tables, parent_Section_assessment_question and assessment_question_multi_choice, my query was like this and it worked
var queryResult =
dsl.select()
.from(PARENT_SECTION)
.join(ASSESSMENT_QUESTION)
.on(PARENT_SECTION.ID.eq(ASSESSMENT_QUESTION.PARENT_SECTION_ID))
.leftJoin(ASSESSMENT_QUESTION_MULTI_CHOICE_OPTION)
.on(
ASSESSMENT_QUESTION_MULTI_CHOICE_OPTION.ASSESSMENT_QUESTION_ID.eq(
ASSESSMENT_QUESTION.ID))
.where(PARENT_SECTION.GATE_ID.eq(gateId))
.fetch()
How should I modify the working query to also list a join between a assessment_Answer_Group( where assessment_answer_Group.entity_id = x) on the questions assessment_answer.answer_group_id
To clarify on the joining structure
I am doing an inner join between parent_section and assessment_Question and a left join between assessment_question and assessment_multi_choice_option
The join between answer_group and assessment_answer is separate from those three tables, it should be where assessment_answer_group.entity_id = x and join on assessment_Answer.answer_Group_id = assessment_answer_Grorup.id
edit: After akinas comments my query is now this, it finds the assessment_answer_group but it does not find any assessment_answers
var queryResult =
dsl.select()
//below line is cross join with an always true join coniditon
.from(PARENT_SECTION.join(ASSESSMENT_ANSWER_GROUP).on(true))
.join(ASSESSMENT_QUESTION)
.on(PARENT_SECTION.ID.eq(ASSESSMENT_QUESTION.PARENT_SECTION_ID))
.leftJoin(ASSESSMENT_QUESTION_MULTI_CHOICE_OPTION)
.on(
ASSESSMENT_QUESTION_MULTI_CHOICE_OPTION.ASSESSMENT_QUESTION_ID.eq(
ASSESSMENT_QUESTION.ID))
.join(ASSESSMENT_ANSWER)
.on(ASSESSMENT_ANSWER_GROUP.ID.eq(ASSESSMENT_ANSWER.ASSESSMENT_ANSWER_GROUP_ID))
.where(PARENT_SECTION.GATE_ID.eq(gateId))