0
我面對一個SQL SELECT問題:SQL SELECT語句的問題
有一個問題,這個問題有一個anwser,而這個答案有一個問題,等等... 這是我的查詢:
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;
這是上面查詢的輸出:
Question 1 | Answer 1 | 2
Question 1 | Answer 2 | 2
Question 2 | Answer 1 | 1
Question 2 | Answer 2 | 1
所以現在的「下一個問題」是一個數字......但我想解決n個下一個問題文本(Q.question)... 我該怎麼做到這一點?
我想是這樣的:
Question 1 | Answer 1 | Question 2
Question 1 | Answer 2 | Question 2
Question 2 | Answer 1 | Question 1
Question 2 | Answer 2 | Question 1
在此先感謝!
我正在使用MySQL。
這是我的表結構:
表 「問題」
+------------------+
| Field |
+------------------+
| questionId |
| question |
+------------------+
表 「答案」
+------------------+
| Field |
+------------------+
| answerId |
| answer |
| nextQuestion |
+------------------+
謝謝!這幫助我了! – Lorenzo 2013-05-12 09:49:02