Select to Schedule in Mysql Meeting Room

Asked

Viewed 475 times

1

Here is the problem: I’m creating a system for scheduling meeting room. I would like to assure you that it will not be possible to schedule the same room for the same period. So after filling out the inclusion form in the table, he checks if the time and room in that period are available. Using the BETWEEN between the start time and the end of the schedule, Example if you already have an appointment from 9am to 11am in the meeting room and try to make the schedule from 8:30 to 9:30 he informs that he can not schedule but when having to make the schedule from 9:30 to 10:30 he leaves, I wonder how I can "reserve" this space so that it does not occur scheduling at the same time.

  • Could post the Query or code you have already implemented?

  • I used the Query below: SELECT * FROM salas_reuniao WHERE meeting_room = '$salaReuniao' AND hour_start BETWEEN '$inicioReuniao' AND '$finalReuniao'

  • And if you tried hour_start > $inicioReuniao AND hour_start < $finalReuniao so if the time the meeting starts between an already booked time you will get a return so it is not possible to book the meeting room at that time

  • For example, if you have a start time in the bank 9:00 and end time 10:00 if you try to put 9:30 will not because it is larger than an initial time and smaller than a registered final time, however placed 10:30 will allow as much as it is larger than a registered initial time is not less than the corresponding final time

  • It worked very well only had to make a modification the end result was that "SELECT * FROM salas_reuniao WHERE meeting_room = '$salaReuniao' AND hour_start <= '$inicioReuniao' AND hour_end >= '$finalReuniao' " Thank you very much for your help

  • I answered the question to help those next who might have the same problem :)

Show 1 more comment

2 answers

1


We have come to the conclusion that to do the following query would solve the need:

SELECT * FROM salas_reuniao WHERE meeting_room = '$salaReuniao' AND hour_start <= '$inicioReuniao' AND hour_end >= '$finalReuniao' 

0

This query solved my scheduling problem

SELECT * FROM booking WHERE space_id = 2
AND :dataInicio BETWEEN dataInicio AND dataTermino
OR :dataFim BETWEEN dataInicio AND dataTermino
OR (
    :dataInicio <= dataInicio 
    AND :dataFim >= dataTermino
)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.