Last post Mar 18, 2020 07:31 AM by Yang Shen
Mar 18, 2020 04:25 AM|hocamahdi99|LINK
How to make select inner join from 3 tables
Mar 18, 2020 07:31 AM|Yang Shen|LINK
What i confuse here is how can i select it from 3 tables,
This is confusing, you have already select the "Before" from these three tables, all you need to do is to implement the approach you found in
the thread on this "Before" output.
Maybe you can SQL SELECT INTO Statement to select this "Before" into a temp table and then deal with this temp table.
select mAttempt.Id as Id ,mAttempt.QuizModelId as QuizId, mAttempt.StartedAt as StartsOn, mUser.UserName,
mDetail.Score as Score
from UserQuizAttemptModels mAttempt, AspNetUsers mUser, QuizAttemptDetailModels mDetail
where mAttempt.UserId=muser.Id and mAttempt.QuizModelId=10053 and mDetail.UserQuizAttemptModelId = mAttempt.Id
Another thing is, the "QuizId" in "Before" is UserQuizAttemptModels.QuizModelId which i assume is the FK of the PK QuizAttemptDetailModels.Id, the QuizAttemptDetailModels.Id value shall be unique since it's PK so the QuizAttemptDetailModels.Id and QuizAttemptDetailModels.Score
should be one to one relationship. While in the "Before", The "QuizId" and "Score" is one to many relationshio which conflicts with my assumptions.
Thus, to avoid redundant guessing, please provide more complete information about these three tables including sample data and anything else necessary to reproduce the situation.
Also, a further description about "select it from 3 tables" could be very helpful. Thanks!