我正在尝试这样的内部联接。
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.
答案 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