I have following table structure
rooms table
||| room_id ||| name |||
||| 1 ||| best |||
||| 2 ||| best |||
||| 3 ||| best |||
||| 4 ||| best |||
bookings table
||| room_id ||| date_start ||| date_end |||
||| 1 ||| 2015-01-10 ||| 2015-01-15 |||
||| 2 ||| 2015-01-10 ||| 2015-01-18 |||
||| 3 ||| 2015-01-05 ||| 2015-01-10 |||
||| 4 ||| 2015-01-02 ||| 2015-01-05 |||
what i want is lets say if a user search for date_start = 2015-01-10 and date_end = 2015-01-14
I want to show the available rooms for those days.
This is what i have tried so far
SELECT r.*
FROM rooms r
WHERE r.room_id NOT IN (
SELECT b.room_id FROM bookings b
WHERE (b.date_start <= '$data[datestart]' AND b.date_end >= '$data[dateend]'))
thank you!