I have two tables like this
rooms
id | number
1 | 111
2 | 112
occupied_rooms
id | check_in | check_out | room_id
1 | 2017-10-01 | 2017-10-04 | 1
I want to get all the unoccupied rooms according to date check_in and check_out for this I tried
select roomsr.id
,rooms r.number
from rooms fromr
`rooms` left join `occupied_rooms`occupied_rooms o
on `rooms`r.`id`id = `occupied_rooms`o.`room_id` room_id
where (`occupied_rooms`o.`check_in`check_in not between "2017-10-05" and "2017-10-08" )
or (`occupied_rooms`o.`check_in`check_in >= "2017-10-05" and `occupied_rooms`o.`check_out`check_out <= "2017-10-08"))
but this query giving me result like this. which is incorrect.
id | number
1 | 111
What is wrong with this query? Thank you for your any help and suggestions