2021年1月27日星期三

How can retrieve Answer and Question table in back end with sql query like this?

I'm using Servlet JSP SQL to write Quiz Application

I have two table in sql like this:

Question(questionID, question_content, status, subjectID)    Choice(choiceID, choice_content, questionID, isTrue)  

1 Question will have 4 answers (1 true - 3 false)

here is my query:

SELECT *, question_content  FROM Choice   INNER JOIN Choice.questionID = Question.questionID  

So result will be like this:

Question 1 - Choice1

Question 1 - Choice2

Question 1 - Choice3

Question 1 - Choice4

...

So the object I receive in back end will like

Obj(Question1, Choice1)

Obj(Question1, Choice2)

...

But what I want is:

Obj(Question1, Choice1, Choice2, Choice3, Choice4)

Is there any way to achieve this or any query suit my need?

https://stackoverflow.com/questions/65930373/how-can-retrieve-answer-and-question-table-in-back-end-with-sql-query-like-this January 28, 2021 at 10:52AM

没有评论:

发表评论