[eluser]DanTheMan[/eluser]
Hi all,
I am used to using active record, however I have become confused with a SQL query I want to use. I am confused because I have a number of constraints within a single where. The following is the SQL.
Code:
SELECT * FROM booking JOIN booking_rooms ON booking.booking_id = booking_rooms.booking_id
WHERE((arrival_date BETWEEN '2011-07-01' AND '2011-07-07')
OR (departure_date BETWEEN '2011-07-01' AND '2011-07-07')
OR (arrival_date < '2011-07-01' AND departure_date > '2011-07-01')
OR (arrival_date < '2011-07-01' AND arrival_date > '2011-07-07')) AND (room_id = 1)
Please could you advise me on the best way for such a query?
Thanks,
Dan