2013-04-10 95 views
0
CREATE TABLE LeadCustomer 
( 
    CustomerID INTEGER NOT NULL, FirstName VARCHAR(20) NOT NULL, 
    Surname VARCHAR(40) NOT NULL, BillingAddress VARCHAR(200) NOT NULL, 
    email VARCHAR(30) NOT NULL  
) 

CREATE TABLE Flight 
(
FlightID INTEGER NOT NULL, FlightDate TIMESTAMP NOT NULL, 
Origin VARCHAR(30) NOT NULL, Destination VARCHAR(30) NOT NULL, 
MaxCapacity INTEGER NOT NULL, PricePerSeat DECIMAL NOT NULL 
) 

CREATE TABLE FlightBooking 
(
BookingID INTEGER NOT NULL, CustomerID INTEGER NOT NULL, FlightID INTEGER NOT NULL, 
NumSeats INTEGER NOT NULL, Status CHAR(1) NOT NULL, BookingTime TIMESTAMP NOT NULL, 
TotalCost DECIMAL 
) 

如果航班重新安排,我們如何生成需要聯繫的客戶列表?Sql加入,更新一個表格並從另一個表格生成輸出

到目前爲止,我已經完成了到:

SELECT 
LeadCustomer.CustomerID,Flight.FlightID 
FROM LeadCustomer 
inner join FlightBooking 
ON LeadCustomer.CustomerID = FlightBooking.CustomerID    
inner join 
Flight ON FlightBooking.FlightID = Flight.FlightID; 

,但不知道如何更新的飛行時間

回答

0

我明白Flight.FlightDate等於FlightBooking.BookingTime。當您更新的第一列,您可以搜索,其中一個成爲不同於其他,如:

SELECT 
LeadCustomer.CustomerID,Flight.FlightID 
FROM LeadCustomer 
inner join FlightBooking 
ON LeadCustomer.CustomerID = FlightBooking.CustomerID    
inner join 
Flight ON FlightBooking.FlightID = Flight.FlightID 
WHERE Flight.FlightDate <> FlightBooking.BookingTime 

如果I'm錯誤你能不能解釋一下更好

相關問題