Select FileUpload.FileName AS FINAME, FileUpload.FilePath,MemberPersonalInformation.FirstName As SharedBy from FileUpload
INNER JOIN
ContentManagement ON ContentManagement.FileId=FileUpload.FileId
INNER JOIN
MemberPersonalInformation ON MemberPersonalInformation.MemberId=ContentManagement.CreatedBy
INNER JOIN
SubjectMaster ON ContentToIndividual.SubjectId=SubjectMaster.SubjectId
where
FileUpload.FileId in
(Select FileId from ContentManagement where ContentId in
(Select ContentId from ContentToIndividual where ShowToMemberId=12)
AND ContentManagement.ContentTypeId=1 and ContentManagement.SessionId=4)
虽然我执行此查询时在最后一个JOIN提示
The multi-part identifier "ContentToIndividual.SubjectId" could not be bound.
时出错,但是两个表中确实都有SubjectId。我不明白是什么问题。请帮帮我。 最佳答案
您正在将SubjectMaster
表连接到以前未引用的ContentToIndividual
表。
您需要先加入contentToIndvidual
,然后再在SubjectMaster
联接中引用它。
例如
Select FileUpload.FileName AS FINAME,
FileUpload.FilePath,MemberPersonalInformation.FirstName As SharedBy
from FileUpload
INNER JOIN
ContentManagement ON ContentManagement.FileId=FileUpload.FileId
INNER JOIN
MemberPersonalInformation ON MemberPersonalInformation.MemberId=ContentManagement.CreatedBy
-- You need to add it in here
Inner Join ContentToIndividual on SomeColumn = AnotherColumn
INNER JOIN
SubjectMaster ON ContentToIndividual.SubjectId=SubjectMaster.SubjectId
where
FileUpload.FileId in
(Select FileId from ContentManagement where ContentId in
(Select ContentId from ContentToIndividual where ShowToMemberId=12)
AND ContentManagement.ContentTypeId=1 and ContentManagement.SessionId=4)
注意:即使您在子查询中查询
ContentToIndividual
,如果它不是主选择查询的一部分,也不能引用其中的列。