sql - MySQL Compare start and finish time -


I am trying to create a booking system, this row in the MySQL table

  room id | Start (date time). | Finnish (Datetime) 13 2014-10-20 08:30 | 2014-10-20 18:30  

And I want to block an entry between these start and end

  Example: Room ID: 13 Start: 2014-10-20 10:30 Expiry: 2014-10-20 12:30  

To do this I created this MySQL query Written, Is this SQL correct? Room

  SELECT * room_id = '13 'AND (' 2014-10-20 12:30:00 '& lt ; = Start_time OR '2014-10-20 10: 30: 00' & gt; = full_time)  

Here I tried to leave the result, please advise me.

You want to be between start time and end time, that means I did not test it But once you try it..I hope it works

  SELECT * from rooms WHERE room_id = '13 'AND (' 2014-10-20 12:30: 00 '& gt; = start_time AND' 2014- 10-20 10: 30: 00 '& lt; = finish_time)  

Comments