Hi Folks...
I am having a little problem with a certain type of query. Allow me to explain. Let' say I have these two tables:
booking table
| idbooking | FK_date | bookingstarttime | bookingendtime |
*primary key is 'idbooking'
*foreign key is 'FK_date' , happens to be the primary of the 'calendar' table.
calendar table
| date | day |
*primary key is 'date'
I am able to do a query that displays the date/day in which there are bookings, however what I really need is the reverse, i.e, the date/day in which there are NO bookings. The query I wrote to display the date/day in which there are bookings is as follows:
Code:
select date, day
from calendar
where date IN(
select FK_date
from booking
);
This works fine, but how do I do the reverse? I tried the following, but none gave the expected result.
Code:
select date,day
from calendar
where date IN !=
(select FK_date
from booking);
Code:
select date,day
from calendar
where date IN (
select date from booking, calendar
where booking.FK_date != calendar.date);
I hope someone can help/advise me. Thanks.