I have a table for service providers that informs the schedule that are not available.
id_prestador | id_pedido | hora_entrada | hora_saida
1 | abc1 | 2017-08-10 10:00:00 | 2017-08-10 14:00:00
2 | xpto2 | 2017-08-10 15:00:00 | 2017-08-10 18:00:00
I need to make an appointment to identify the providers that are available at the requested time, for example:
Timetable requested: Entry: 2017-08-10 08:00:00 Checkout: 2017-08-10 11:00:00
In this example it would bring the provider 2
Any light? Thank you!
Resolved:
SELECT *
FROM fcs_prestadores_pedidos
WHERE hora_entrada not BETWEEN '2017-08-10 16:00:00' AND '2017-08-10 18:00:00'
AND hora_saida not between '2017-08-10 16:00:00' AND '2017-08-10 18:00:00'