Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
sqlontherun101
Starting Member
16 Posts |
Posted - 2009-06-28 : 01:43:10
|
hi, I have two entities Question and Answer. Business rule says that 1. A Question can have many answers (4 answers) PK- QID2. An ANswer can be in Many Questions PK - AIDTherefore i have added a bridging table called "QuestionwithAnswers"and i have added "QID" and "AID" as PK (composite) for "QuestionwithAnswers". Assume i have to search for a Question and it's answers, How do i perform that using those three tables? "Question" table has the following attributes:QIDStatementcorrectAnswer"Answer" table has the following attributes:AIDStatement"QuestionwithAnswers" table has the following attribute:AIDQID |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-06-28 : 01:54:06
|
use INNER JOINselect *from QuestionwithAnswer qa inner join Question q on qa.QID = q.QID inner join Answer a on qa.AID = a.QID KH[spoiler]Time is always against us[/spoiler] |
|
|
|
|
|