无法绑定多部分标识符“Reservation.ReservationID”

时间:2010-10-12 11:59:45

标签: sql sql-server-2005

我正在尝试这样的内部联接。

select R.ReservationID, R.BookingNumber,P.FirstName, P.LastName  
from Reservation R inner join PersonName P 
on Reservation.ReservationID = PersonName.ResrvationID 

我收到的错误是:

Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Reservation.ReservationID" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "PersonName.ResrvationID" could not be bound.

2 个答案:

答案 0 :(得分:4)

别名“R”和“P”掩盖了实际的表名。

虽然这里不适用,但一般来说都是有意义的。例如,当您有自我加入时

select R.ReservationID, R.BookingNumber,P.FirstName, P.LastName  
from Reservation R inner join PersonName P 
on R.ReservationID = P.ReservationID --use aliasas

答案 1 :(得分:1)

尝试改为

select 
  R.ReservationID
, R.BookingNumber
, P.FirstName
, P.LastName   

from Reservation R 
inner join PersonName P  
on R.ReservationID = P.ResrvationID