I an trying to write a SELECT statement that excludes results where the car has already been booked on a given day.
My code selects info from table Car_Details and links to table Booking_Details to get the dates that a car is already booked on.
Car 'AA11 AAA' is booked for both of the days '2019-05-09' and '2019-05-08' and car 'BB22 BBB' is not booked on any day.
The tables are linked using the Key Car_Registration
SELECT Car_Details.Car_Registration
FROM Car_Details, Booking_Details
WHERE Car_Details.Car_Active='Y'
AND NOT(Booking_Details.Car_Registration=Car_Details.Car_Registration)
AND Booking_Details.Booking_Date='2019-05-09')
GROUP BY Car_Details.Car_Registration;
When run I expect the result to be only car 'BB22 BBB' but instead I get both cars 'AA11 AAA' and 'BB22 BBB' appearing.
How do I edit this code so only car 'BB22 BBB' appears?