I have 3 tables:
tbl_question (id,question)
tbl_answer (id,answer)
question_has_answer (id,question_id,answer_id)
It looks like many-to-many association, but in fact it is only used like 1-to-many (one question has multiple answers, but each answer belongs to only question). So I need to get fields (except id) from first and second table like this:
Question1
answer1
answer2
answer3
Question2
answer5
answer4
and so on.
Would be:
I would also recommand not using an ID for table question_has_answer, if you don’t plan to use that ID.
And further more: if 1 answer is associated with only 1 question, than you shouldn’t use question_has_answer and modify tbl_answer to add a questionID column.