Sql-server 2005中的内部联接问题
|
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中显示错误消息“ 1”,但是两个表中确实都有SubjectId。我不明白是什么问题。请帮帮我。
没有找到相关结果
已邀请:
2 个回复
死狸蔽垂藐
表连接到先前未引用的
表。 您需要先加入
才能在
Join中引用它。 例如
注意:即使您要在子查询中查询“ 3”,但如果它不是主选择查询的一部分,也不能引用其中的列。
贡炮逗握惫
或
联接,因为您没有从任何一个表中选择任何列-请记住,子查询与主查询是分开的;您仅使用它来获取FileId列表。也有可能优化语句的其余部分。
编辑2:只是为了好玩,我认为这可以简化一些事情,因为它摆脱了子查询,因此应该更快。