Hi Newbie here.
Im trying to design a query that will allow me to tell if I have a record in my db that matches.
The fields I have in my db are
cid(int)
resort(int)
villa(int)
startdate(date yyyy-mm-dd)
enddate(date yyyy-mm-dd)
slot (am/pm)
the only record i have in there at this moment in time is
cid=1
resort=1
villa=1
startdate=2006-08-06
enddate=2006-08-12
slot=am
In my query if I have a direct match on the following fields I return a result, 'villa','startdate','enddate' and 'slot'.
Now thats all well and good however I also need to take into account the fact the startdate could be later or the enddate could be earlier :-
Select * from bookings Where villa=1 AND startdate='2006-08-07' AND enddate='2006-08-11' AND slot=pm.
whats making this harder for me to understand is that I can have an overlap on the enddate as long as the slot is different. SO:-
Select * from bookings Where villa=1 AND startdate='2006-08-12' AND enddate='2006-08-16' AND slot=pm.
would still be valid even though the startdate is clashing as the slot is different.
I hope this makes sense and thanks
CHris