vendredi 27 janvier 2017

Ordered Randomness

Can someone please help me with this query?

Questions:

  • ID - Autonum
  • Question - Memo
  • Category - Integer(1-5)

Answers:

  • ID - Autonum
  • FID - Integer
  • Answer - Memo

One question, many possible answers

I need a query that will show all questions from category#1 in random order. After each question, it will show it's possible answers also in random order. Then it will do it for category#2 and so on.

Here's what I have so far:

SELECT Questions.ID, Questions.Question, Questions.Category, Answers.Answer
FROM Questions INNER JOIN Answers ON Questions.ID = Answers.FID
ORDER BY Questions.Category, RND(Questions.ID);

It correctly keeps all the categories together but the rest is random. I'm not sure how to keep the Questions.ID's together (but in a random order) while making the answers order random also.




Aucun commentaire:

Enregistrer un commentaire