简体   繁体   English

odbc调用失败[microsoft] [sql server本机客户端11.0] [sql server]多部分标识符盘绕不绑定

[英]odbc call failed [microsoft] [sql server native client 11.0] [sql server] the multipart identifier coild not be bound

I have two queries, which use tables linked using an ODBC database, both are simple enough and individually work fine. 我有两个查询,它们使用通过ODBC数据库链接的表,两个查询都非常简单并且可以单独工作。

Query #1: 查询1:

SELECT 
    People.First_name, People.Last_name, Awards.[Award Name], 
    Recipients.Affiliation, Recipients.Recipient_Award_Comments, 
    Recipients.Recipient_Date, People.PersonID 
FROM
    People 
INNER JOIN 
    (Awards 
INNER JOIN 
    Recipients ON Awards.AwardID = Recipients.AwardID) ON People.PersonID = Recipients.PersonID;

Query #2: 查询2:

SELECT 
    Awards.[Award Name], People.First_name, People.Last_name, 
    Contenders.Contender_Date_Assigned, 
    Contenders.Award_Contender_Comments, People.PersonID
FROM 
    people, contenders, awards
WHERE 
    Awards.AwardID = Contenders.AwardID 
    AND People.PersonID = Contenders.PersonID;

I tried using a left join on these queries ( which works fine on access , but on migrating the data to SQL Server) I am getting this error: 我尝试在这些查询上使用左联接(在access上工作正常,但是在将数据迁移到SQL Server上)我收到此错误:

odbc call failed [microsoft] [sql server native client 11.0] [sql server] the multipart identifier 'Contenders.PersonID' could not be bound, 'Contenders.AwardID' could not be bound and 'Awards.AwardID' could not be bound. odbc调用失败[microsoft] [sql server native client 11.0] [sql server]不能绑定多部分标识符'Contenders.PersonID','Contenders.AwardID'和'Awards.AwardID'。

On doing an inner join it works fine but it isn't what I want. 在进行内部联接时,它工作正常,但这不是我想要的。

Query r+c 查询r + c

SELECT 
    Query1.First_name, Query1.Last_name, Query1.[Award Name], 
    Query1.Affiliation, Query1.Recipient_Award_Comments, 
    Query1.Recipient_Date, Query2.First_name, Query2.Last_name, 
    Query2.[Award Name], Query2.Contender_Date_Assigned, 
    Query2.Award_Contender_Comments, Query1.PersonID
FROM
    Query1 
LEFT JOIN 
    Query2 ON Query1.PersonID = Query2.PersonID;

You can do : 你可以做 :

with Query11 as
(
   <Query11 goes here>
), Query22 as
(
   <Query22 goes here>
)

select  q1.First_name, q1.Last_name, Query1.[Award Name], 
        q1.Affiliation, q1.Recipient_Award_Comments, 
        q1.Recipient_Date, q2.First_name, Query2.Last_name, 
        q2.[Award Name], q2.Contender_Date_Assigned, 
        q2.Award_Contender_Comments, q1.PersonID
from Query11 q1 left join
     Query22 q2
     on q2.PersonID = q1.PersonID; 

I would rewrite the Query11 as : 我将Query11重写为:

SELECT p.First_name, p.Last_name, a.[Award Name], 
       r.Affiliation, r.Recipient_Award_Comments, 
       r.Recipient_Date, p.PersonID 
FROM People p INNER JOIN 
     Recipients r
     ON p.PersonID = r.PersonID INNER JOIN
     Awards a
     ON a.AwardID = r.AwardID;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误= [Microsoft] [SQL Server本机客户端11.0] - Error = [Microsoft][SQL Server Native Client 11.0] 无法运行查询:SQLSTATE [42000]:[Microsoft] [SQL Server Native Client 11.0] [SQL Server]&#39;)&#39;附近的语法不正确 - Failed to run query: SQLSTATE[42000]: [Microsoft][SQL Server Native Client 11.0][SQL Server]Incorrect syntax near ')' Microsoft SQL Server本机客户端11.0:无法打开数据库 - Microsoft SQL Server Native Client 11.0 : Cannot open database 不绑定SQL Server查询多部分标识符 - SQL Server query multipart Identifier cound not be bound [Microsoft] [SQL Server本机客户端11.0] SQL Server网络接口:连接字符串无效 - [Microsoft][SQL Server Native Client 11.0]SQL Server Network Interfaces: Connection string is not valid 经典ASP Microsoft SQL Server本机客户端11.0错误&#39;80040e14&#39;用户登录失败,但不是我指定的用户登录 - Classic ASP Microsoft SQL Server Native Client 11.0 error '80040e14' Login failed for user, but not the one I specified SQL Server在ASP经典版[Microsoft]中执行SQL存储过程时出错[SQL Server Native Client 11.0] [SQL Server]错误 - SQL Server Error executing SQL stored procedure in ASP classic [Microsoft][SQL Server Native Client 11.0][SQL Server] Error sqlcmd:本机客户端11.0不支持到SQL Server 2000的连接 - sqlcmd: Native Client 11.0 does not support connections to SQL Server 2000 SSIS OLE DB 记录可用。 来源:“Microsoft SQL Server Native Client 11.0” Hresult:0x80004005,无法确定元数据 - SSIS An OLE DB record is available. Source: "Microsoft SQL Server Native Client 11.0" Hresult: 0x80004005, The metadata could not be determined 如何在 ODBC 本机客户端中获取 SQL Server DateTime2 字段 - How to get SQL Server DateTime2 field in ODBC native client
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM