问题是:您希望成为第一个预订航班座位的人。查找没有预订的所有航班的flight_num
和日期。
从下表中:
Flights
(flight_num, source_city, dest_city
)Departures
(flight_num, date, plane_type
)Passengers
(passenger_id, passenger_name, passenger_address
)Bookings
(passenger_id, flight_num, date, seat_number
)我的回答是:
SELECT D.flight_num, D.date
FROM DEPARTURES D, BOOKINGS B
WHERE B.passenger_id = NULL
我知道这是错的,但任何人都可以告诉我为什么?这是什么答案?
答案 0 :(得分:1)
这可能会更好:
SELECT D.flight_num, D.date
FROM DEPARTURES D JOIN BOOKINGS B ON D.flight_num = B.flight_num
WHERE B.passenger_id IS NULL
我不确定是否可以预订,但不预订座位号码。如果是,则需要更改WHERE子句。
答案 1 :(得分:0)
这可能有用吗?
SELECT D.flight_num, D.date
FROM Departures D LEFT OUTER JOIN Bookings B
WHERE B.passenger_id IS NULL