1

ちょっとしたクイズ用にこれらの 3 つのテーブルがあります。各問題には 1 つの正解と 3 つの不正解があります

テーブル名: 列:
質問 QuestionID、QuestionText、
                            AnswerID (正解のIDを格納)

回答 AnswerID、AnswerText、QuestionID
QuestionsAnswers QuestionID,AnswerID

このクエリ

SELECT QuestionText, AnswerText
FROM [Questions] LEFT OUTER JOIN [Answers]
ON Questions.QuestionID=Answers.AnswerID;

次の結果が得られます

What is the capital of England? London
What is the capital of France?  Paris
What is the capital of USA?         Washington

実際には、各質問にグループ化された他の 3 つの間違った回答も表示する必要があります。みたいな

 What is the capital of England?    London
 What is the capital of England?    Berlin
 What is the capital of England?    BikiniBottom
 What is the capital of England?    Nottingham
 ... -- more results for France, USA and others follow

上記のクエリを変更して同様の結果を得るにはどうすればよいですか? ありがとう

4

4 に答える 4

3

SELECT QuestionText, AnswerText FROM [回答] LEFT OUTER JOIN [質問] ON Answers.QuestionID=Questions.QuestionID;

于 2013-08-07T08:50:14.717 に答える
2

上記のテーブル構造から、どうですか

SELECT QuestionText, AnswerText
FROM [Questions] LEFT OUTER JOIN [Answers]
ON Questions.QuestionID=Answers.QuestionID;

注意しAnswers.QuestionIDないでくださいAnswers.AnswerID

于 2013-08-07T08:49:25.330 に答える
2

これを試して

SELECT QuestionText, AnswerText
FROM [Questions] LEFT OUTER JOIN [Answers]
ON Questions.QuestionID=Answers.QuestionID;
于 2013-08-07T08:49:47.543 に答える
1

たぶん、QuestionsAnswers以下のソリューションに参加する必要があります

SELECT QuestionText, AnswerText
FROM [Questions] 
JOIN [QuestionsAnswers] ON QuestionsAnswers.QuestionID=QuestionsAnswers.AnswerID;
JOIN [Answers] ON QuestionsAnswers.AnswerID=Answers.AnswerID;
于 2013-08-07T08:51:26.930 に答える