Select Query

Discussion in 'MySQL' started by zed420, Aug 31, 2009.

  1. #1
    Hi All
    I've managed to get somewhere with the query below with some help but it has a small problem after rigorous testing I found there is a small glitch e.g. Let’s say if I book from 10:00 to 13:00 and someone tries to book it from 08:00 to 21:00 (all day) IT WILL BOOK, meaning it will over lap. I have tried to sort it but failing miserably, anyone with any thoughts
    Thanks
    Zed

    SELECT b_id, COUNT(*) AS Cnt 
    	FROM booking 
    	WHERE request_date='$request_date' AND 
    	( 
       ($s_time >= s_time AND $s_time < e_time) OR 
       ($e_time > s_time AND $e_time <= e_time) 
    	) 
    	GROUP BY b_id
    Code (markup):

     
    zed420, Aug 31, 2009 IP
  2. zed420

    zed420 Member

    Messages:
    60
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #2
    Thanks everyone I've managed to sort it, this is what it looks like

    SELECT COUNT(*) AS Cnt
    FROM booking
    WHERE request_date = '$request_date'
    AND $e_time > s_time
    AND $s_time < e_time
     
    zed420, Sep 1, 2009 IP