与多个表联接 [英] Join with Multiple Tables
问题描述
我收到以下问题的语法错误,似乎无法弄清楚,希望大家能帮帮我!
I am getting a syntax error with the following problem and can't seem to figure out, hope you guys can help me!
我有这些表(已填充):
I have these tables (they are populated):
我正在尝试检索在某个航班号中安排的所有乘客的名字和姓氏,所以我是这样的:
I am trying to retrieve the first and last name of all the passengers scheduled in a certain flight number so what I have is this:
SELECT PassFName, PassLName
FROM Passenger
INNER JOIN PassID ON Passenger.PassID = Reservation.PassID
INNER JOIN FlightNum ON FlightNum.Reservation = FlightNum.ScheduledFlight
WHERE ScheduledFlight.FlightNum = [Enter Flight Number];
但是,我遇到了错误:
不知道为什么,在最后一行中我也注意到它拼写了FlightNum.ScheduledFlight.知道我在做什么错吗?
Not sure why and I have also noticed in the last line it is misspelling FlightNum.ScheduledFlight. Any idea what am I doing wrong?
谢谢!
推荐答案
戈登的观点是正确的,但是他的括号放错了位置,并且错过了其他大问题.这个查询不只一点点,表名和字段名也被翻转了.这是我猜想会起作用的...
Gordon's point is valid, but he's got his parentheses misplaced and missed the other big issues. This query is more than a little whacked, with table names and field names flip-flopped. Here's what I would guess would work...
SELECT
PassFName
, PassLName
FROM (
Passenger
INNER JOIN Reservation
ON Passenger.PassID = Reservation.PassID
)
INNER JOIN ScheduledFlight
ON Reservation.FlightNum = ScheduledFlight.FlightNum
WHERE
ScheduledFlight.FlightNum = [Enter Flight Number];
这篇关于与多个表联接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!