You could create a trigger (Trigger) to run before entering the record in the table, like the example below, assuming you use the table "table_reservations" with the columns "quarto_id", "checkin" and "checkout":
CREATE TRIGGER `tabela_reservas_BEFORE_INSERT` BEFORE INSERT ON `tabela_reservas` FOR EACH ROW
BEGIN
IF(SELECT count(*) as total FROM tabela_reservas as tr WHERE NEW.quarto_id = tr.quarto_id AND ((NEW.checkin >= tr.checkin AND NEW.checkin <= tr.checkout) OR (NEW.checkout >= tr.checkin AND NEW.checkout <= tr.checkout)))
THEN
-- AQUI VC IMPLEMENTA O QUE DESEJA FAZER NOS CASOS DE DUPLICIDADE (LEMBRANDO QUE ATÉ AQUI O NOVO REGISTOR AINDA NÃO FOI INSERIDO NO BANCO)
END IF;
END
Welcome(to), Click here and see how Sopt works Take advantage too, and see how to create a Minimum, Complete & Verifiable example
– rubStackOverflow
See if it helps http://forum.imasters.com.br/topic/477535-resolvidoregistros-no-intervalo-de-2-datas/#entry1897617
– Motta