-1

Here are my tables from SQLite :

Table1 - QUIZ

quiz_id

quiz_name

quiz_dateofcreation

quiz_key

Table2 - QUESTION

question_id

question_name

question_type (it could be S_answer or MCQ_answer)

quiz_id_fk

Table3 - S_ANSWER (standard answer)

s_answer_id

s_answer_name

question_id_fk

Table4 - MCQ_ANSWER (multiple choice answer)

mcq_answer_id

mcq_answer_name

mcq_answer_type (it could be correct or wrong)

question_id_fk

I want to send data to server for one QUIZ .Example when user click on send quiz data ,it wil be sended. DB on server is similiar, additional table for user.

First problem for me is SQL statement to get all data per QUIZ...

Second problem for me is best way to send data, i suppose first data retrieved with sql convert to JSON like Convert SQLite to JSON and then send them with help android volley class If there is best way .. please let me now...

Community
  • 1
  • 1
Tomislav
  • 13
  • 5

1 Answers1

0
select
     QUIZ.quiz_name
     ,QUESTION.question_name
     ,ANSWER.answer_name
     ,MCQ_ANSWER.mcq_answer_name
from QUIZ
     left join QUESTION on QUESTION.quiz_id_fk = QUIZ.quiz_id
     left join ANSWER on ANSWER.question_id_fk = QUESTION.question_id
     left join MCQ_ANSWER on MCQ_ANSWER.question_id_fk = QUESTION.question_id
//where QUIZ.quiz_id = ...

This query will join all the tables you need so you can select any data you wish for any table. I'm not sure how you will be passing the quiz_id but where is the where clause you would use. I'm not sure how your data works so I used left joins but you can alter to your needs. I have only selected a few columns from the tables but you get the point....

Stivan
  • 1,128
  • 1
  • 15
  • 24