I am writhing a query for a hotel reservation and booking system but I got a problem with selecting rooms was not reserved between two date . my query is alike this but it's not working as well and query return noting but actually I have 3 room with room type 1 . Sql fiddle : http://sqlfiddle.com/#!2/b97419
SELECT tbl_room.room_no, tbl_room.type_id, tbl_Reservation.room_id
FROM tbl_room
LEFT JOIN tbl_Reservation ON tbl_room.id = tbl_Reservation.room_id
WHERE (
(
tbl_Reservation.checkin_data < '" . $checkin . "'
AND tbl_Reservation.checkout_data < '" . $checkin . "'
)
OR (
tbl_Reservation.checkin_data > '" . $checkout . "'
AND tbl_Reservation.checkout_data > '" . $checkout . "'
)
)
AND tbl_room.type_id =1
thanks for your helping and sorry for my bad english .