gpt4 book ai didi

c# - Sql-server 2005 中的内部连接问题

转载 作者:太空宇宙 更新时间:2023-11-03 18:43:41 26 4
gpt4 key购买 nike

   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 表。

在您的 SubjectMaster 加入中引用它之前,您需要加入 contentToIndvidual

例如

 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,如果它不是主选择查询的一部分,您也不能引用其中的列。

关于c# - Sql-server 2005 中的内部连接问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6356679/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com