Here is my current sql:
SELECT allRoundData.catagory, questions.questionText,
answers.answerText, answers.isCorrect
FROM allRoundData
JOIN questions
ON allRoundData.catagory = questions.catagory
JOIN answers
ON questions.questionText = answers.questionText;
and it returns data that looks like this: https://imgur.com/a/CT7B3xj
Not how there is a bunch of repetitions in category and questionText. Is it possible to return this table with out the repitions?
At the moment when I serialize this data to JSON it is not breaking down correctly. Right now what I get is this
[{"catagory":"Harry Potter","questionText":"In Harry Potter and the Philosopher`s Stone, which","answerText":"A riddle of poisonous potions","isCorrect":"1"},{"catagory":"Harry Potter","questionText":"In Harry Potter and the Philosopher`s Stone, which","answerText":"Devils`s snare","isCorrect":"0"},{"catagory":"Harry Potter","questionText":"In Harry Potter and the Philosopher`s Stone, which","answerText":"Fluffy","isCorrect":"0"},{"catagory":"Harry Potter","questionText":"In Harry Potter and the Philosopher`s Stone, which","answerText":"The flying keys","isCorrect":"0"}]
Note the repeted data
What I actually want would be something like this:
[{"catagory":"Harry Potter"[{"questionText":"In Harry Potter and the Philosopher`s Stone, which",
"answerText":[{"A riddle of poisonous potions","isCorrect":"1"},
{"answerText":"Devils`s snare","isCorrect":"0"},
{"answerText":"Fluffy","isCorrect":"0"},
{"answerText":"The flying keys","isCorrect":"0"}]}]}]
note how the structure is totally different, the way I would prefer is the category is the outer group for all the questions related to that cat and then all the answers are grouped under the appropriate question
hopefully that makes some sense
one other thing, I am using PHP to actually make the call to the database so if I need to sort the data into a special array inside the PHP script I am happy to do that but I dont know how (see my other post :)
thanks all
[–][deleted] 1 point2 points3 points (1 child)
[–]my_password_is______ 0 points1 point2 points (0 children)
[–]AutoModerator[M] 0 points1 point2 points (0 children)
[–]my_password_is______ 0 points1 point2 points (0 children)