I am trying to create a booking system and now I have 2 tables. One containing caravans that are held on a site and another using the caravan number as a foreign key containing booking information such as dates booked and for which customer. So far I have a query that runs to make sure no caravans are double booked by displaying the available caravans. It looks like this:
SELECT TblCaravan.[Caravan No]
FROM TblCaravan INNER JOIN TblCaravanBooking ON TblCaravan.[Caravan No] = TblCaravanBooking.[Caravan No]
WHERE (((TblCaravanBooking.[When Required])>Forms!Booking.When_Required And (TblCaravanBooking.[When Required])>Forms!Booking.Required_Until)) Or (((TblCaravanBooking.[Required Until])<Forms!Booking.When_Required And (TblCaravanBooking.[Required Until])<Forms!Booking.Required_Until))
ORDER BY TblCaravan.[Caravan No];
This works but as you can tell it would only show the ones that already have bookings made. How can I show the caravans that are available but don't already have bookings so don't show in TblCaravanBooking? Please help. This needs to be within the same query?
SELECT TblCaravan.[Caravan No]
FROM TblCaravan INNER JOIN TblCaravanBooking ON TblCaravan.[Caravan No] = TblCaravanBooking.[Caravan No]
WHERE (((TblCaravanBooking.[When Required])>Forms!Booking.When_Required And (TblCaravanBooking.[When Required])>Forms!Booking.Required_Until)) Or (((TblCaravanBooking.[Required Until])<Forms!Booking.When_Required And (TblCaravanBooking.[Required Until])<Forms!Booking.Required_Until))
ORDER BY TblCaravan.[Caravan No];
This works but as you can tell it would only show the ones that already have bookings made. How can I show the caravans that are available but don't already have bookings so don't show in TblCaravanBooking? Please help. This needs to be within the same query?