获取sql查询中的多部分标识符错误

时间:2013-05-13 20:03:03

标签: sql sql-server

在我的SQL查询中,我收到错误:

  

无法绑定多部分标识符“a.Position_ID”。

我不确定是什么造成的。有人可以帮忙吗?

感谢。

select distinct 
   a.HireLastName, a.HireFirstName, a.HireID, a.Position_ID, a.BarNumber, 
   a.Archived, a.DateArchived, b.Position_Name
from NewHire a, WorkPeriod c
join Position b on a.Position_ID = b.Position_ID
where 
    a.Archived = 0 
    and a.HireID = c.HireID 
    and c.InquiryID is not null 
order by 
    a.HireID DESC, a.HireLastName, a.HireFirstName

1 个答案:

答案 0 :(得分:1)

您的代码未加入表格c,我认为这可能会导致您的别名出现问题a。你能试试这个:

select distinct 
    a.HireLastName, 
    a.HireFirstName, 
    a.HireID, 
    a.Position_ID, 
    a.BarNumber, 
    a.Archived, 
    a.DateArchived, 
    b.Position_Name
from NewHire a 
join Position b on a.Position_ID = b.Position_ID
join WorkPeriod c on a.hireID = c.HireID
where a.Archived = 0 and c.InquiryID is not null 
order by a.HireID DESC, a.HireLastName, a.HireFirstName