Hi, OK. im trying to design a query that will show me whether I have anything booked within a date range.

basically I have this table
id, (primary)
cid, (int)
resort, (int)
villa, (int)
startdate, (date yyyy-mm-dd)
enddate, (date yyyy-mm-dd)
adults, (int)
children, (int)
infno, (varchr)
outfno, (varchr)
atime, (varchr)
slot, (int ,0 or 1)

what I need is a query that will pull back a record ONLY if the following conditions are met.

villa = $var
endate <= $var
slot <> $var

Im having trouble making this work I have tried multiple different aproaches but cant get any to work how I think they should. My best guess is below, however I think its falling down on the date element, Im not sure if I can use that operator on a date field.

Query:

SELECT * FROM booking WHERE villa = '1' AND enddate <= '2006-08-12' AND slot <> '0'



The above works as long as 'enddate' = $var I cant get it look backwards into the date if that makes sense!!!!

Many thanks
Chris