Time redunduncy

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tomex
    New Member
    • Feb 2010
    • 6

    Time redunduncy

    hello guys..
    I have trouble on what should i do. i am making a system where in a student may reserve a station with a start time and end time. my problem is what should i do so that the time entered in a station number may not conflict with a new entered time on the same station ex.


    ResNo .......... STATION........ . STARTTIME ......... ENDTIME
    1 ............... ... 1.............. .......2:00.... ............... .....3:00
    2 ............... .....1*........ .......... 2:30*.......... ............ 3:00 *

    *how would i know that it would not conflict on the first resrvation

    thanks guys i really appreciate your help right now..=)

    its online i'm using php and mySQL as my DBMS
    Last edited by tomex; Feb 26 '10, 09:51 AM. Reason: forgot what code i am needing
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hey.

    You can use the BETWEEN ... AND ... operator to figure that out.

    A select statement using two of those, checking whether the start and the end were within another range, should work.
    [code=sql]
    SELECT ...
    WHERE '02:30' BETWEEN `start` AND `end`
    AND '03:00' BETWEEN `start` AND `end`
    [/code]
    Something like that would give you a list of all rows that collided with your given range. If this came up empty, you would be OK to reserve the new range.

    Comment

    Working...