1
Tenants (HouseID, ApartmentNumber, LeaseTenantSSN, LeaseStartDate(not null), LeaseExpirationDate(can be null),
Rent, LastRentPaidDate, RentOverdue)
NewRentPayments (HouseID, ApartmentNumber, LeaseTenantSSN(not null), Rent(can be null), DatePaid)
查詢
INSERT INTO Tenants (x.HouseID,x.ApartmentNumber,x.LeaseTenantSSN,CURRENT_DATE,NULL,x.Rent,x.Rent,FALSE)
SELECT x.HouseID, x.ApartmentNumber,x.LeaseTenantSSN,CURRENT_DATE,NULL,x.Rent,x.Rent
FROM NewRentPayments x
WHERE x.HouseID NOT IN (select HouseID
FROM Tenants)
OR x.ApartmentNumber NOT IN (SELECT ApartmentNumber
FROM Tenants
WHERE Tenants.HouseID=x.HouseID);
我總是在CURRENT_DATE錯誤,NULL.It說在sintax錯誤或在CURRENT_DATE附近
謝謝,把x.DatePaid放在你的問號上。 – daniel