I encountered an error message that says:
Multi-part identifier cannot be boundduring the initial join, specifically relating to
PatientSurvey.PatientSurveyId
. I’m working with SQL Server. Here’s the query I ran:SELECT PatientSurvey., CompletedItem.
FROM PatientSurvey, CompletedItem
JOIN SurveyResponseIteration ON SurveyResponseIteration.PatientSurveyId = PatientSurvey.PatientSurveyId
AND SurveyResponseIteration.IterationId = 4
WHERE PatientSurvey.CompletedItemId = CompletedItem.CompletedItemId
Interestingly, when I change up the order of the clauses, the error disappears. For instance, this query works fine:SELECT PatientSurvey., CompletedItem.
FROM PatientSurvey, CompletedItem
JOIN SurveyResponseIteration ON SurveyResponseIteration.IterationId = 4
WHERE PatientSurvey.CompletedItemId = CompletedItem.CompletedItemId
AND PatientSurvey.PatientSurveyId = SurveyResponseIteration.PatientSurveyId
I’m puzzled as to why the identifier PatientSurvey.PatientSurveyId
is not recognized in the first query, but it is in the second. Can anyone explain this?