I'm facing a SQL SELECT problem:
There is a question, this question has an anwser, and this answer has a next question, and so on... This is my query:
SELECT Q.question, A.answer, A.nextQuestion as 'next question' from answers A join questions Q on A.nextQuestion = V.questionId
order by Q.question;
This is the output of the above query:
Question 1 | Answer 1 | 2
Question 1 | Answer 2 | 2
Question 2 | Answer 1 | 1
Question 2 | Answer 2 | 1
So right now the 'next question' is a number... But I'd like to resolve that number to the next question text (Q.question)... How can I achieve this?
I want something like this:
Question 1 | Answer 1 | Question 2
Question 1 | Answer 2 | Question 2
Question 2 | Answer 1 | Question 1
Question 2 | Answer 2 | Question 1
Thanks in advance!!
I'm working with MySQL.
This is my table structure:
Table "Questions"
+------------------+
| Field |
+------------------+
| questionId |
| question |
+------------------+
Table "Answers"
+------------------+
| Field |
+------------------+
| answerId |
| answer |
| nextQuestion |
+------------------+