Ver Mensaje Individual
  #8 (permalink)  
Antiguo 18/12/2015, 13:28
Avatar de manyblue
manyblue
 
Fecha de Ingreso: marzo-2008
Mensajes: 329
Antigüedad: 16 años
Puntos: 10
Respuesta: Consulta MySQL Habitaciones Hotel

En primer lugar, muchas gracias por tu respuesta.
Solo me asalta una duda... ¿Realmente creas un registro en la tabla "tbl_fechas_habitaciones" por cada día reservado? ¿Es correcto?
SI es correcto.
Creo que ya lo soluciones, xD, si no, corrigeme:
Código:
SELECT
tbl_fechas_habitaciones.idFecha_Habitacion,
tbl_fechas_habitaciones.refHabitacion,
tbl_fechas_habitaciones.fechas,
tbl_hotel.strNombre,
tbl_hotel.intCategoria,
tbl_habitaciones_hotel.refTipo_Habitacion,
tbl_habitaciones_hotel.refImagenes,
tbl_habitaciones_hotel.intEstado,
tbl_habitaciones_hotel.intNumero_Habitacion,
tbl_habitaciones_hotel.refHotel,
tbl_habitaciones_hotel.id_Habitacion,
tbl_hotel.idHotel,
tbl_habitaciones_hotel.refUsuario,
tbl_habitaciones_hotel.intPrecio_Especial,
tbl_habitaciones_hotel.intPrecio_Alta,
tbl_habitaciones_hotel.intPrecio_Media,
tbl_habitaciones_hotel.intPrecio_Baja,
tbl_habitaciones_hotel.strDescuento,
tbl_habitaciones_hotel.intDescuento_Estado,
tbl_habitaciones_hotel.intPromocion,
tbl_habitaciones_hotel.strPromocion_Contenido,
tbl_habitaciones_hotel.strDescripcion,
tbl_habitaciones_hotel.intAdultos,
tbl_habitaciones_hotel.intNinos,
tbl_habitaciones_hotel.intBebes,
tbl_hotel.intEstado,
tbl_hotel.dblLatitud,
tbl_hotel.dblLongitud,
tbl_hotel.idProvincia,
tbl_hotel.strPoblacion,
tbl_hotel.strResumen,
tbl_hotel.intNumero_Habitaciones,
tbl_hotel.strEmail,
tbl_hotel.strTelefono
FROM
tbl_fechas_habitaciones
INNER JOIN tbl_habitaciones_hotel ON tbl_fechas_habitaciones.refHabitacion = tbl_habitaciones_hotel.id_Habitacion
INNER JOIN tbl_hotel ON tbl_habitaciones_hotel.refHotel = tbl_hotel.idHotel
WHERE
tbl_hotel.intEstado = 1 AND tbl_habitaciones_hotel.intEstado = 1 AND tbl_hotel.idProvincia = 43
AND tbl_habitaciones_hotel.id_Habitacion NOT IN(SELECT DISTINCT (tbl_fechas_habitaciones.refHabitacion) FROM tbl_fechas_habitaciones
WHERE tbl_fechas_habitaciones.fechas BETWEEN '2015-12-18' AND '2015-12-28')
GROUP BY tbl_fechas_habitaciones.refHabitacion
La consulta me arroja este resultado:

refHabitacion Fecha
1 2016-01-01
3 2016-01-05

La Habitacion id 1 tienes reservados desde el 2016-01-01 al 2016-01-07
La Habitacion id 3 tiene reservados desde el 2016-01-05 al 2016-01-16
La Habitacion id 2 tiene reservados desde el 2015-12-18 al 2015-12-31

¿¿ Nos vamos acercando o creo que ya está ??

Conclusión: es que el buscador me dice que hay dos habitaciones libres en las fechas seleccionadas la 1 y la 3 además la consulta me da las fechas que están ocupadas de esas dos Habitaciones. Que lio..........

Un saludo: Manyblue